Merge pull request #2279 from keepassxreboot/fix/autocomplete_menu_min_width

Fix Autocomplete Menu widths
This commit is contained in:
Sami Vänttinen 2024-08-07 14:22:05 +03:00 committed by GitHub
commit 61db82045f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -329,8 +329,13 @@ class Autocomplete {
return;
}
// Calculate Y offset if menu does not fit to the bottom of the screen -> show it at the top of the input field
// Set container's minimum width to the input field's width
const rect = this.input.getBoundingClientRect();
this.container.style.minWidth = Pixels(this.input.offsetWidth);
// Extend the list's max width to input field's width or at least to the maxWidth defined in the CSS file
this.list.style.maxWidth = `max(${Pixels(this.input.offsetWidth)}, 600px)`;
// Calculate Y offset if menu does not fit to the bottom of the screen -> show it at the top of the input field
const menuRect = this.container.getBoundingClientRect();
const totalHeight = menuRect.height + rect.height;
const menuOffset = totalHeight + rect.y > window.self.visualViewport.height ? totalHeight : 0;