Skip to content

Conversation

@ealonas
Copy link

@ealonas ealonas commented Dec 5, 2025

Summary:

We are using the definition widget in Assessments for ELA (and probably Math at some point). These changes bring us closer to the accessibility requirements to be compliant with WCAG.

Issue: AX-2119

Test plan:

  • unit tests
  • do the following manual steps with and without the screenreader:
  1. Open popover
  2. Observe focus on popover close button
  3. Hit Escape key
  4. Observe popover close
    --
  5. Open popover
  6. Observe focus on popover close button
  7. Hit Tab
  8. Observe popover close
    --
  9. Open popover
  10. Observe focus on popover close button
  11. Hit Shift + Tab (tab backwards)
  12. Observe popover close

Without Screenreader

test-no-screenreader.mov

With Screenreader

test-with-screenreader.mov

<full summary>

Issue: <url or "none">

Test plan:
<see below>
…board experience. We are enabling closing the definition widgets popover for tooltips in two new ways: hitting the escape key, tabbing out of the popover (forwards or backwards).
@ealonas ealonas self-assigned this Dec 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

Size Change: +39 B (+0.01%)

Total Size: 499 kB

Filename Size Change
packages/perseus/dist/es/index.js 202 kB +39 B (+0.02%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.8 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/index.js 99.2 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 13.1 kB
packages/perseus-core/dist/es/index.js 22.6 kB
packages/perseus-editor/dist/es/index.js 98.2 kB
packages/perseus-linter/dist/es/index.js 8.64 kB
packages/perseus-score/dist/es/index.js 9.2 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 7.73 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.72 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (ab8930c) and published it to npm. You
can install it using the tag PR3094.

Example:

pnpm add @khanacademy/perseus@PR3094

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3094

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3094

@ealonas ealonas requested a review from aag December 5, 2025 16:46
<DefinitionConsumer>
{({activeDefinitionId, setActiveDefinitionId}) => (
<Popover
dismissEnabled
Copy link
Author

Choose a reason for hiding this comment

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

This enables closing when hitting the escape key or tapping out.

@ealonas ealonas marked this pull request as ready for review December 5, 2025 18:43

// Assert - Popover should be closed
expect(screen.queryByRole("dialog")).toBeNull();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend adding a test that shows that other keyboard events do not close the popover.

Copy link
Author

Choose a reason for hiding this comment

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

Thats a good idea! Any in particular you'd recommend?

Copy link
Contributor

@mark-fitzgerald mark-fitzgerald left a comment

Choose a reason for hiding this comment

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

Thank you for improving the accessibility of this widget!

Copy link
Contributor

@ivyolamit ivyolamit left a comment

Choose a reason for hiding this comment

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

@ealonas changes looks logical to me. I'm wondering if this accessibility needs be addressed in WonderBlock level since this is using PopoverContentCore. Though this is the closest I can find in the docs https://khan.github.io/wonder-blocks/?path=/docs/packages-popover-popover-accessibility--docs

<View
onKeyDown={(e) => {
// Close popover when tabbing off the close button
// (the only tabbable element in the popover)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have anything that enforces that no other clickable elements appear in the popover, but the style guide for content creators says to only use basic text, so this should be safe within Khan Academy. I wonder if we need to do something more for other users.

Copy link
Member

@aag aag left a comment

Choose a reason for hiding this comment

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

This seems pretty good to me, though the solution might have to change once we move to Floating UI for the Popover. I'd like to get @jandrade to weigh in on the change, since he's working on the Floating UI migration.

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.

5 participants