Skip to content

fix: preserve pending a11y status messages#1693

Open
puneetdixit200 wants to merge 1 commit into
downshift-js:masterfrom
puneetdixit200:fix-multiselect-add-status-message
Open

fix: preserve pending a11y status messages#1693
puneetdixit200 wants to merge 1 commit into
downshift-js:masterfrom
puneetdixit200:fix-multiselect-add-status-message

Conversation

@puneetdixit200
Copy link
Copy Markdown

Pull Request

What

Fixes an aria-live status edge case where an empty status message can cancel a pending non-empty status update from another useA11yMessageStatus caller.

Why

When hooks such as useMultipleSelection and useSelect are composed together, one hook can have a real status message ready while a neighboring hook reports no status for the same render cycle. The empty status should be a no-op, not a cancellation of the pending message. This is related to #1298.

How

useA11yMessageStatus now returns early when getA11yStatusMessage returns an empty value, before the shared debounced updater is called.

Changes

  • Added a regression test covering two status hook callers where the second returns an empty status.
  • Skipped scheduling live-region updates for empty status messages.

Checklist

  • Documentation N/A
  • Tests
  • TypeScript Types
  • Ready to be merged

Verified with:

  • CI=true npm test -- src/hooks/utils/__tests__/useA11yMessageStatus.multiple.test.ts --runInBand
  • CI=true npm test -- src/hooks/utils/__tests__/useA11yMessageStatus.test.ts --runInBand
  • CI=true npm test -- src/hooks/useMultipleSelection/__tests__/props.test.js --runInBand
  • CI=true npm test -- src/hooks/useSelect/__tests__/props.test.js --runInBand
  • npm run test:ts
  • npx prettier --check src/hooks/utils/useA11yMessageStatus.ts src/hooks/utils/__tests__/useA11yMessageStatus.multiple.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants