Automatically set an ID on active combobox options#102
Open
henrycatalinismith wants to merge 5 commits intogithub:mainfrom
Open
Automatically set an ID on active combobox options#102henrycatalinismith wants to merge 5 commits intogithub:mainfrom
henrycatalinismith wants to merge 5 commits intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for combobox options that do not already have IDs by auto-assigning a temporary ID to the currently selected option so aria-activedescendant can still point to it. It fits into the library’s accessibility behavior around keyboard navigation and selected-option tracking.
Changes:
- Add temporary ID assignment/removal for selected options that are missing an
id. - Track whether the selected option’s ID was auto-assigned so it can be cleaned up on navigation/clear.
- Add tests covering navigation across options with and without predefined IDs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/index.ts |
Adds runtime logic to synthesize and later remove selected-option IDs. |
test/test.js |
Adds coverage for options missing IDs and verifies ID lifecycle during navigation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+443
to
+461
| assert.equal(list.children[2].getAttribute('id'), undefined) | ||
|
|
||
| press(input, 'ArrowDown') | ||
| assert.equal(input.getAttribute('aria-activedescendant'), 'hubot') | ||
| assert.equal(list.children[0].getAttribute('id'), undefined) | ||
| assert.equal(list.children[1].getAttribute('id'), 'hubot') | ||
| assert.equal(list.children[2].getAttribute('id'), undefined) | ||
|
|
||
| press(input, 'ArrowDown') | ||
| assert.equal(input.getAttribute('aria-activedescendant'), 'list-id-selected') | ||
| assert.equal(list.children[0].getAttribute('id'), undefined) | ||
| assert.equal(list.children[1].getAttribute('id'), 'hubot') | ||
| assert.equal(list.children[2].getAttribute('id'), 'list-id-selected') | ||
|
|
||
| press(input, 'Escape') | ||
| assert.equal(input.getAttribute('aria-activedescendant'), undefined) | ||
| assert.equal(list.children[0].getAttribute('id'), undefined) | ||
| assert.equal(list.children[1].getAttribute('id'), 'hubot') | ||
| assert.equal(list.children[2].getAttribute('id'), undefined) |
|
|
||
| if (target === el) { | ||
| if (!target.id) { | ||
| target.id = `${this.list.id}-selected` |
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.
Reopening #99 here after accidentally closing it while cleaning out unused old forks. Sorry!