From ef819ea959fbab0849724529538f9a9912173aa3 Mon Sep 17 00:00:00 2001 From: Mark Fitzgerald <13896410+mark-fitzgerald@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:52:05 -0800 Subject: [PATCH] [Numeric Input] - Link tooltip content to input field for assistive technologies (#1891) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary: Currently, the format options tooltip for the input field is only available to sighted users. People using assistive technologies (like braille or screen readers) are unaware of any formatting options for their answers. This change will add an element adjacent to the input field that includes the content of the tooltip, and an association between the two so that assistive technologies can make use of the format options. Issue: LEMS-2458 ## Test plan: 1. Launch Storybook 1. Navigate to Perseus Editor => Editor => [Demo](http://localhost:6006/?path=/story/perseuseditor-editorpage--demo) 1. Add a Numeric Input widget 1. Configure the widget to have any number of format options ![Storybook - 1 Format Option](https://github.com/user-attachments/assets/a46af08c-cc6d-48a6-b20f-4b48c560023d) 1. Using the keyboard, tab to the close icon in the top right of the preview area ![Storybook - Close Icon](https://github.com/user-attachments/assets/a75b4447-4015-460f-8e91-76a71d46de6f) 1. Launch VoiceOver (or your preferred screen reader) 1. Tab to the input field in the preview 1. The screen reader should read the same content as what shows in the tooltip ![VoiceOver - 1 Format Option](https://github.com/user-attachments/assets/fa6bed95-5446-44f7-8cd5-7ec68b860495) 1. Multiple format options should be read with an "or" conjunction in the phrase ![VoiceOver - 3 Format Option](https://github.com/user-attachments/assets/16fc3ef9-bd53-4b65-a355-777919779600) ## Affected behavior: ### Before ![VoiceOver - Before](https://github.com/user-attachments/assets/12ee2a44-ef61-4d80-8120-600d4aa143f4) ### After ![VoiceOver - 1 Format Option](https://github.com/user-attachments/assets/911d1b53-9ea3-4758-bbd5-4a6f04aae901) Author: mark-fitzgerald Reviewers: SonicScrewdriver Required Reviewers: Approved By: SonicScrewdriver Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ gerald Pull Request URL: https://github.com/Khan/perseus/pull/1891 --- .changeset/odd-moons-remember.md | 5 +++ .../server-item-renderer.test.tsx.snap | 13 ++++++ .../src/components/input-with-examples.tsx | 23 +++++++++- .../perseus/src/components/text-input.tsx | 2 + packages/perseus/src/components/tooltip.tsx | 1 + .../multi-renderer.test.tsx.snap | 13 ++++++ .../graded-group-set-jipt.test.ts.snap | 18 ++++++++ .../graded-group-set.test.ts.snap | 6 +++ .../group/__snapshots__/group.test.tsx.snap | 12 +++++ .../__snapshots__/numeric-input.test.ts.snap | 32 +++++++++++++ .../numeric-input/numeric-input.test.ts | 45 +++++++++++++++++++ 11 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 .changeset/odd-moons-remember.md diff --git a/.changeset/odd-moons-remember.md b/.changeset/odd-moons-remember.md new file mode 100644 index 0000000000..3ff9692b33 --- /dev/null +++ b/.changeset/odd-moons-remember.md @@ -0,0 +1,5 @@ +--- +"@khanacademy/perseus": patch +--- + +[Numeric Input] - Associate format options tooltip content with input field for assistive technologies diff --git a/packages/perseus/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap b/packages/perseus/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap index 8e79ffdd65..a1c1828e6c 100644 --- a/packages/perseus/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap +++ b/packages/perseus/src/__tests__/__snapshots__/server-item-renderer.test.tsx.snap @@ -41,6 +41,7 @@ exports[`server item renderer should snapshot: initial render 1`] = `
+