-
Notifications
You must be signed in to change notification settings - Fork 20
Automatically set an ID on active combobox options #99
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
base: main
Are you sure you want to change the base?
Changes from all 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 |
|---|---|---|
|
|
@@ -126,11 +126,17 @@ | |
| el.removeAttribute('data-combobox-option-default') | ||
|
|
||
| if (target === el) { | ||
| if (!target.id) { | ||
| target.id = `${this.list.id}-selected` | ||
| } | ||
| this.input.setAttribute('aria-activedescendant', target.id) | ||
| target.setAttribute('aria-selected', 'true') | ||
|
Comment on lines
+129
to
133
|
||
| fireSelectEvent(target) | ||
| target.scrollIntoView(this.scrollIntoViewOptions) | ||
| } else { | ||
| if (el.id === `${this.list.id}-selected`) { | ||
| el.removeAttribute('id'); | ||
|
Check failure on line 138 in src/index.ts
|
||
|
francinelucca marked this conversation as resolved.
francinelucca marked this conversation as resolved.
|
||
| } | ||
| el.removeAttribute('aria-selected') | ||
|
francinelucca marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
|
||
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.
This change introduces new behavior for options without ids (auto-assigning and moving
${list.id}-selected). There are existing tests foraria-activedescendantbehavior intest/test.js, but none cover the missing-id path; please add tests to validate id assignment, id movement across options, and cleanup when selection is cleared/stopped.