feat: add focusSelectedItem flag to combo-box#9194
Draft
DiegoCardoso wants to merge 1 commit intomainfrom
Draft
Conversation
| comboBox.addEventListener('vaadin-combo-box-dropdown-opened', resolveFocusSelectedItem); | ||
| // `_onOpened` doesn't re-run on filter change, so the web component can't | ||
| // re-arm its own `__shouldFocusSelectedItem` latch — re-resolve ourselves. | ||
| comboBox.addEventListener('filter-changed', () => { |
Contributor
There was a problem hiding this comment.
I think I would prefer if it would not do that. If I enter a new filter, I likely want to select a different item. Based on the filtered results I then want to scan the list from top to bottom. Then it doesn't sound helpful that it scrolls down somewhere to the current selection.
Adds ComboBox.setFocusSelectedItem(boolean) / isFocusSelectedItem() and an @ClientCallable resolveSelectedItemIndex() that returns an authoritative flat index for the current value via ItemIndexProvider (lazy data) or the list data view (in-memory). Falls back silently to the web-component's best-effort behavior when neither is available. The connector wires a vaadin-combo-box-dropdown-opened listener with token-based "switch" cancellation for overlapping filter changes / pending fetches, plus a filter-changed re-resolve and a close-side needsDataCommunicatorReset arm — the latter prevents a stuck loading state when the scroller re-requests the same viewport range the server last sent on reopen. Includes ComboBoxFocusSelectedItemPage + ComboBoxFocusSelectedItemIT (23 tests covering regression guards, filter interactions, domain-type / binder / detach-reattach / throwing-ItemIndexProvider edge cases, plus an A6 regression guard for the reopen stuck-loading bug). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cfa1c60 to
81e662d
Compare
|
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
Adds
ComboBox.setFocusSelectedItem(boolean)/isFocusSelectedItem()and an@ClientCallable resolveSelectedItemIndex()that returns an authoritative flat index for the current value viaItemIndexProvider(lazy) or the list data view (in-memory), with silent fallback to the web-component's best-effort behavior when neither is available.The connector (
comboBoxConnector.js) wires avaadin-combo-box-dropdown-openedlistener with token-based "switch" cancellation for overlapping filter changes / pending fetches, plus afilter-changedre-resolve and a close-sideneedsDataCommunicatorResetarm. The latter prevents a stuck loading state when the scroller re-requests the same viewport range the server last sent on reopen.Fixes vaadin/web-components#6061.
Depends on
Cannot merge until both of these land in `vaadin/web-components`:
Test plan
🤖 Generated with Claude Code