Repository navigation
Prevent Enter from selecting after Virtual Select is disabled - #494
Xapollon430 wants to merge 3 commits into
Conversation
PR Test Results — ✅ all checks passed
Tested commit: |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change preventing Enter actions while Virtual Select is disabled.
No open issues 🎉
What changed in this PR
Prevents Enter from opening the dropdown or committing a focused option after Virtual Select is disabled, while preserving existing popup visibility behavior.
Changes:
- Checks the root disabled state before handling either Enter action.
- Adds a Cypress regression confirming that disabling an open, focused Select prevents keyboard selection and emits no
changeevent.
| File | Description |
|---|---|
src/virtual-select.js |
Returns early from the Enter handler when the Select is disabled. |
cypress/e2e/a11y-disable-while-open.cy.ts |
Tests keyboard navigation and Enter after disabling an open searchable Select. |
Review effort: Balanced
|
@Xapollon430 can you please share a reproduction sample we can validate? |
gnbm
left a comment
There was a problem hiding this comment.
Thanks for the fix! Two small notes on the test and the manual repro page below.
| <div id="fruit"></div> | ||
| <p id="status" role="status">Enabled</p> | ||
| <p>Change count <output id="changes">0</output></p> | ||
| <script src="../assets/virtual-select.js"></script> |
There was a problem hiding this comment.
This page loads ../assets/virtual-select.js, but the committed bundle in docs/assets still has the old onEnterPress (else if (this.$ele.disabled === false)), since the PR only changes src/. Following the steps on the page as committed (open, ArrowDown to Orange, wait for "Disabled", Enter) still selects Orange and bumps the change count to 1.
Could you rebuild docs/assets in this PR, or add a note on the page that it needs a fresh build?
| keydown('ArrowDown', 40); | ||
| keydown('ArrowDown', 40); | ||
| cy.get(`#${mountId} .vscomp-option.focused`).should('not.have.attr', 'data-value', 'o1'); |
There was a problem hiding this comment.
This assertion requires ArrowDown to keep moving the highlight after disable(), which locks in behaviour we probably don't want. A more complete fix (closing the dropbox on disable, or ignoring arrow keys while disabled) would make this line fail.
Suggestion: move the ArrowDown presses and highlight check before host.disable(), then after disabling assert that Enter (and ideally ArrowDown) are ignored.
Problem
disable()while its search field has focus and the dropdown is open.changefires.Watch the Chromium reproduction. The recording uses ordinary keyboard input and the library’s stylesheet against current
masterat129b893. Pointer selection is already blocked in this layout; the focused search input can still commit the highlighted option.Check the root disabled state before Enter can either open the dropdown or select the focused option. The popup’s existing visibility behavior is unchanged.
I investigated this transition in Anta with Hegel and Bombadil, then reproduced it independently here.
Validation
changeevent fires.AI-assisted implementation and testing.
Reviewer follow-up: added a standalone reproduction at
docs/examples/disabled-keyboard.html. Runnpm ci,npm run build, andnpx docsify serve docs -p 3001, then openhttp://localhost:3001/examples/disabled-keyboard.htmland follow the instructions.The reported CI failure was caused by shared page state in the live-region suite. Enabling page isolation for that suite fixes it. All 421 browser tests pass in Chrome, including the disabled-keyboard regression. Build, source lint, and type check pass.