diff --git a/assets/javascripts/autocomplete.js b/assets/javascripts/autocomplete.js index bc24cd0..49fd54e 100644 --- a/assets/javascripts/autocomplete.js +++ b/assets/javascripts/autocomplete.js @@ -10,6 +10,10 @@ let ac = $(this).autocomplete({ appendTo: "body", minLength: 2, + // Kept on screen: on a phone a wide list of suggestions widened the page, which could leave the page + // stuck scrolled to the side + classes: { "ui-autocomplete": "line-item-suggestions" }, + position: { my: "left top", at: "left bottom", collision: "flipfit" }, source: function(request, response) { $.getJSON("/items/autocomplete", { q: request.term }) diff --git a/assets/stylesheets/line_items.css b/assets/stylesheets/line_items.css index a46132a..672622c 100644 --- a/assets/stylesheets/line_items.css +++ b/assets/stylesheets/line_items.css @@ -244,7 +244,17 @@ table.list.line-items-table td:nth-child(n+2) { pointer-events: none; } -/* Item suggestions */ +/* Item suggestions: no wider than the screen, long descriptions wrap */ +.ui-autocomplete.line-item-suggestions { + max-width: calc(100vw - 16px); + box-sizing: border-box; +} + +.line-item-suggestions .autocomplete-item { + white-space: normal; + overflow-wrap: anywhere; +} + .autocomplete-item { line-height: 1.2; } @@ -263,6 +273,13 @@ table.list.line-items-table td:nth-child(n+2) { color: #999; } +/* Phones and narrow windows: Redmine's page wrapper hides what sticks out sideways but can still be scrolled + sideways by the browser (bringing a field or list into view), with no way to swipe it back. Clipping + instead keeps it in place. */ +@media screen and (max-width: 899px) { + #wrapper { overflow-x: clip; } +} + /* Phones: each line becomes a small card (number, description and delete; quantity, price and total) */ @media screen and (max-width: 699px) {