Skip to content

CORE-4450: Keep the focused highlight selected when clearing focus styles - #3229

Open
RoyEJohnson wants to merge 8 commits into
mainfrom
CORE-4450-keep-focused-highlight
Open

RoyEJohnson wants to merge 8 commits into
mainfrom
CORE-4450-keep-focused-highlight

Conversation

@RoyEJohnson

@RoyEJohnson RoyEJohnson commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.update now passes the focused highlight to clearFocusedStyles, 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 undefined is 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.tsx and PageWithMockedHighlighter.spec.tsx pass (44 tests).
  • tsc fails on highlightManager.ts with "Expected 0 arguments, but got 1", because package.json still has highlighter v1.18.0, where clearFocusedStyles takes no argument. The other two errors are the existing ones on main.
  • Not run: the full suite and the coverage gate.
  • Retest with NVDA and Firefox on Windows once this is built: Tab to a highlight (expect one announcement), then Tab into the note card and Shift+Tab back (expect one announcement, not two).

🤖 Generated with Claude Code

…tyles

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@TomWoodward
TomWoodward temporarily deployed to rex-web-core-4450-keep--qfarn1 December 3, 2026 17:23 Inactive
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@TomWoodward
TomWoodward temporarily deployed to rex-web-core-4450-keep--mftxcm December 3, 2026 18:45 Inactive
@RoyEJohnson
RoyEJohnson requested an adaptive review from Copilot December 3, 2026 18:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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)

@RoyEJohnson
RoyEJohnson marked this pull request as ready for review December 3, 2026 18:52
@RoyEJohnson
RoyEJohnson requested a review from a team as a code owner December 3, 2026 18:52
@RoyEJohnson
RoyEJohnson requested a review from jivey December 3, 2026 18:52
@TomWoodward
TomWoodward temporarily deployed to rex-web-core-4450-keep--mftxcm December 3, 2026 19:33 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-core-4450-keep--mftxcm December 3, 2026 20:26 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-core-4450-keep--mftxcm December 3, 2026 21:51 Inactive

@jivey jivey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@TomWoodward
TomWoodward temporarily deployed to rex-web-core-4450-keep--mftxcm December 4, 2026 16:57 Inactive
@TomWoodward
TomWoodward temporarily deployed to rex-web-core-4450-keep--mftxcm December 4, 2026 20:14 Inactive

This branch was successfully deployed

1 active and 1 inactive (outdated) deployments
rex-web-core-4450-keep--mftxcm — edb0b83b Deployed Dec 4, 2026 by TomWoodward
rex-web-core-4450-keep--qfarn1 — 77016d2b Deployed Dec 3, 2026 by TomWoodward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants