-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FirstOptionSelectionMode
:selected
clearing on typing
#82
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -108,7 +108,7 @@ export default class Combobox { | |||||||
const focusIndex = els.indexOf(focusEl) | ||||||||
|
||||||||
if ((focusIndex === els.length - 1 && indexDiff === 1) || (focusIndex === 0 && indexDiff === -1)) { | ||||||||
this.clearSelection() | ||||||||
this.resetSelection() | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is the case where the user reaches the end of the options in either direction. Based on current behavior I think we do want to clear the selection in this case, not just reset it: Screen.Recording.2024-02-26.at.9.35.13.AM.movMight be good to add a test for this, but it's not a blocker IMO.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we clear the selection here instead; this will also be a regression in behaviour for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense! Updated in dbf90b5 |
||||||||
this.input.focus() | ||||||||
return | ||||||||
} | ||||||||
|
@@ -141,10 +141,11 @@ export default class Combobox { | |||||||
for (const el of this.list.querySelectorAll('[aria-selected="true"]')) { | ||||||||
el.removeAttribute('aria-selected') | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should probably also remove
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally, that's a good catch, will add! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 7182ef5 🙇 |
||||||||
} | ||||||||
} | ||||||||
|
||||||||
if (this.firstOptionSelectionMode === 'active') { | ||||||||
this.indicateDefaultOption() | ||||||||
} | ||||||||
resetSelection(): void { | ||||||||
this.clearSelection() | ||||||||
this.indicateDefaultOption() | ||||||||
} | ||||||||
anleac marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
} | ||||||||
|
||||||||
|
@@ -189,7 +190,7 @@ function keyboardBindings(event: KeyboardEvent, combobox: Combobox) { | |||||||
break | ||||||||
default: | ||||||||
if (event.ctrlKey) break | ||||||||
combobox.clearSelection() | ||||||||
combobox.resetSelection() | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't comment on unchanged lines (maybe one day 🙏) but I think maybe we should replace the
indicateDefaultOption
call on line82
withresetSelection
, just to make sure the state is cleared when the menu opens. It's shouldn't be necessary since selection is cleared on close, but it feels safer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 7182ef5