Dynamic width for autocomplete suggestions dropdown widget #173
Open
hexycat wants to merge 3 commits intoMaxteabag:mainfrom
Open
Dynamic width for autocomplete suggestions dropdown widget #173hexycat wants to merge 3 commits intoMaxteabag:mainfrom
hexycat wants to merge 3 commits intoMaxteabag:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The width of the
AutocompleteDropdownwidget is now explicitly set on every call of theset_itemsmethod, determined by the longest item in the visible suggestion list plus border/padding/scrollbar offsets.Reason
Currently the width of the dropdown is always set to
min-widthregardless of its content or themax-widthvalue. The likely reason is related to thewidth: autoCSS property of the dropdown combined with thewidthCSS property of the parent container, which results in the width being constrained tomin-width.This is especially noticeable when table names share long identical prefixes.

In such case suggestions may look like this:
After changes:

Changes
_update_widthmethod toAutocompleteDropdownclass.It computes and sets the width of the dropdown from the longest visible suggestion plus border/padding/scrollbar offsets, clamped between
MIN_WIDTH(25) andMAX_WIDTH(80).The method is called at the end of
set_items, so the width is updated whenever the list of visible suggestions changestests/ui/test_autocomplete_dropdown.pycovering the new expected width behaviour ofAutocompleteDropdown