Repository navigation
fix: size the options list for a new option added in single select - #495
Merged
Merged
Conversation
With allowNewOption in single select, selectOption() closes the dropbox
before beforeSelectNewValue() persists the new option. The close clears
the search, and setVisibleOptionsCount() drops the temporary current-new
option and sizes the list without it. The fallback branch then re-adds
the option through addOption() with no rerender, and the deferred
setSearchValue('') is a no-op because the search is already empty.
The list therefore came back one row short: 0px on an empty list, with
has-no-options still applied. Recount once the option is persisted.
Multi select is unaffected because it never closes on select.
PR Test Results — ✅ all checks passed
Tested commit: |
"uses the singular form for a single match" typed "Option 3" key by key. Only the full term narrows the list to one match, so it is the one search case where a lost keystroke changes the result. In CI the search box ended with "Opt" and the region correctly said "5 results available"; the rest of the keys went elsewhere. Wait until the component has focused the search input itself, then set the term with a single input event and assert the input holds it before checking the region. The announcement still goes through the real input handler and its focus check, and a singular/plural regression still fails the test.
gnbm
marked this pull request as ready for review
November 17, 2026 11:28
os-davidlourenco
approved these changes
Nov 23, 2026
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.
Issue number: resolves #496
What is the current behavior?
With
allowNewOption: trueandmultiple: false, adding a new option leaves the options list one row short. On an empty list the list is0pxtall andhas-no-optionsstays on, so the option just added is hidden. Each later addition stays one row behind. Multi select works because it never closes on select.The cause is an ordering issue in
selectOption():closeDropbox()runs first and clears the search.setVisibleOptionsCount()then drops the temporaryisCurrentNewoption and sizes.vscomp-options-listandhas-no-optionswithout it.beforeSelectNewValue()then takes the fallback branch added in feature(search): Include option descriptions in search when searchNormalize is true; fix add-new-option crash #464. It re-adds the option throughsetNewOption()→addOption(), which does not rerender.setSearchValue('')returns early because the search is already empty, so nothing recounts.What is the new behavior?
beforeSelectNewValue()callssetVisibleOptionsCount()after the option is persisted. The list height, the visible count andhas-no-optionsnow include the new option.setVisibleOptionsCount()was chosen over forcingsetSearchValue('', false, true)because it has no announce or focus side effects.addOption(data, true)was ruled out becauseafterSetOptions()withoutkeepValuecallsreset()and would clear the selected value.cypress/e2e/single-select-new-option-height.cy.tsadds two options to an empty single select and checks the list height after each one.Does this introduce a breaking change?
Other information
0pxvs40px,40pxvs80px)lint:jsandtypecheckBuilt
dist/,docs/assets/anddist-archive/files are not part of this PR, matching earlier fix PRs.