Repository navigation
CORE-4450: Keep the focused highlight selected when clearing focus styles - #3229
RoyEJohnson wants to merge 8 commits into
Conversation
…tyles Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The requested NVDA/Firefox-on-Windows retest is still needed because mocked highlighter tests cannot confirm that returning focus from the note card produces only one announcement.
No open issues 🎉
What changed in this PR
Preserves the focused highlight’s selected state during style updates to address duplicate screen-reader announcements in CORE-4450. NVDA verification remains pending.
Changes:
- Passes the focused highlight to
clearFocusedStyles. - Adds tests for focused and unfocused states.
- Updates highlighter to version 1.18.1.
| File | Description |
|---|---|
yarn.lock |
Locks highlighter to the 1.18.1 commit. |
src/app/content/components/Page/highlightManager.ts |
Preserves focused highlight styles during updates. |
src/app/content/components/Page/highlightManager.spec.tsx |
Tests both arguments passed to clearFocusedStyles. |
package.json |
Updates the highlighter dependency to 1.18.1. |
Review effort: Balanced (adaptive)
jivey
left a comment
There was a problem hiding this comment.
I tested this fairly extensively with NVDA and FireFox and it still exhibits the double "start selected" announcement when Shift+Tabbing back to the highlight (only while in Browse mode - in Focus mode, it's read once, but that matches production right now.) I'm not sure if this can be changed, I think it happens because of the forced focus, which is kind of unavoidable since we can't place the button right next to the highlight in the DOM. Maybe you have some other ideas for making it work, I can retest if you push updates.
I found an instance of it improving the rewrite from 2 to 1 when changing color with the card open, but didn't really find it changing it when tabbing in and out, so I'll approve if that's a helpful improvement. But we should probably point it at a different ticket in that case.
https://openstax.atlassian.net/browse/CORE-4450
Companion to openstax/highlighter#113. Incorporates highlighter 1.18.1
NVDA speaks "Start selected yellow highlight" twice when focus returns to an already-selected highlight. REX supplies its own
onFocusIn, so the highlighter's default handler never runs. REX applies focus styles in its update loop, which clears the styles on every highlight and then adds them back to the focused one. That rewrites the focused start span's name twice.Change
highlightManager.updatenow passes the focused highlight toclearFocusedStyles, so it stays selected. The highlighter change skips the second write, because the name already matches.Two tests: the highlight is passed when one is focused, and
undefinedis passed when none is.Behavior to check
I read the cause from Otto's Speech Viewer log against the code. It has not been confirmed with NVDA. A pending or scroll-target highlight can also be the one that gets focus in the update loop, and this change only protects the highlight already marked as focused.
Testing
highlightManager.spec.tsxandPageWithMockedHighlighter.spec.tsxpass (44 tests).tscfails onhighlightManager.tswith "Expected 0 arguments, but got 1", becausepackage.jsonstill has highlighter v1.18.0, whereclearFocusedStylestakes no argument. The other two errors are the existing ones onmain.🤖 Generated with Claude Code