Skip to content

RichText: let Tab leave the color swatch groups (#1944) - #2202

Open
spaulah wants to merge 1 commit into
pnp:devfrom
spaulah:issue-1944
Open

spaulah wants to merge 1 commit into
pnp:devfrom
spaulah:issue-1944

Conversation

@spaulah

@spaulah spaulah commented Nov 23, 2026

Copy link
Copy Markdown

Title: RichText: fix keyboard focus trapped in Font Color / Highlight color swatch groups

Q A
Bug fix? [x]
New feature? [ ]
New sample? [ ]
Related issues? fixes #1944

What's in this Pull Request?

Every color group in the Font Color and Highlight color callouts is rendered by SwatchColorPickerGroup, which wrapped
its swatches in a FocusZone with handleTabKey={FocusZoneTabbableElements.all} and isCircularNavigation. The zone
took Tab/Shift-Tab and wrapped them inside the group, so focus could never get back to "Automatic" / "No color" or move
on to "Standard colors".

Changes:

  • SwatchColorPickerGroup.tsx: removed handleTabKey (and the now unused import), as proposed in the issue. Each group is now a
    single Tab stop: Tab/Shift-Tab move between the default button and the groups, and Left/Right move between swatches
    inside a group (still circular).
  • SwatchColorPickerGroup.test.tsx (new): Tab on the last/middle swatch and Shift-Tab on the first swatch leave the
    group, arrow keys wrap at both ends, one Tab stop per group. The three Tab tests fail on dev and pass with the fix.

Testing:

  • npm run build passes on Node 22 (all jest suites green, no new lint warnings).
  • Checked by hand in the SharePoint workbench (controlsTest web part, RichText > More): Tab, Shift-Tab and Left/Right
    in the color pickers.

No public API change. I left out the optional bidirectional switch from my issue comment (Up/Down between swatch
rows), and #1942 / #1943 will be separate PRs.

Each color group in the Font Color and Highlight color callouts is a
FocusZone with handleTabKey={FocusZoneTabbableElements.all} and
isCircularNavigation. The zone handled Tab/Shift-Tab itself and wrapped
them inside the group, so keyboard users couldn't get back to
"Automatic"/"No color" or move on to "Standard colors".

Remove handleTabKey so the zone uses its default. Each group is now one
Tab stop, and the arrow keys still move between swatches (circular).

Add SwatchColorPickerGroup tests for Tab/Shift-Tab leaving the group,
circular arrow keys and the single Tab stop.

Fixes pnp#1944

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you for the first contribution to this project.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

1 participant