From ec6956ef25f575cc10438e2fc1ab45040bd5c2ce Mon Sep 17 00:00:00 2001 From: varjolintu Date: Fri, 12 Jul 2024 07:57:53 +0300 Subject: [PATCH] Fix Autocomplete Menu widths --- keepassxc-browser/content/autocomplete.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/keepassxc-browser/content/autocomplete.js b/keepassxc-browser/content/autocomplete.js index 541602b..1e01b9f 100644 --- a/keepassxc-browser/content/autocomplete.js +++ b/keepassxc-browser/content/autocomplete.js @@ -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;