Fix input collapses for multi select & no placeholder & no initial selection - #1374
Fix input collapses for multi select & no placeholder & no initial selection#1374muendlein wants to merge 1 commit into
Conversation
| } | ||
| this.input.setWidth(); | ||
|
|
||
| if (this._placeholderValue || this._store.items.length > 0) { |
There was a problem hiding this comment.
Any reason to not simplify this check to just?
else if (this._store.items.length) {
There was a problem hiding this comment.
I'm not sure if I fully understand your suggestion but if (this._store.items.length) should always evaluate to true as items are initialized as [].
There was a problem hiding this comment.
In javascript, [].length === 0. but if length is a positive value, then it is truthy. However the real fix probably should be in setWidth
setWidth(): void {
// Resize input to contents or placeholder
const { element } = this;
element.style.minWidth = `${element.placeholder.length + 1}ch`;
element.style.width = `${element.value.length + 1}ch`;
}
This should have had a minimum length of 1, but obviously something isn't working as expected; likely for element.value.length term.
There was a problem hiding this comment.
The this._store.items aren't populated when _createStructure() is called, so this check doesn't work as expected
|
Looking into this more, removing the logic which reduces the input to 1ch causes reflow issues when multiple items are selected on a narrow enough display port |
|
Ah, after some tinkering this is a more general issue with no placeholders or no items causing the total height of the entire choices.js widget to dramatically shrink. This change doesn't fix that, and just bandaids the issue |
Description
Fixes #1368
Types of changes
Checklist