-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WB-1891]: Integrating Announcer into SingleSelect and MultiSelect #2495
Open
marcysutton
wants to merge
27
commits into
feature/announcer
Choose a base branch
from
combobox-announcer-v2
base: feature/announcer
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c65354d
[combobox-announcer] Expose string or node from opener
marcysutton 683d837
[combobox-announcer] Extract function into helper file
marcysutton 59d42f2
[combobox-announcer] Move announcer types into src
marcysutton 10c94a8
[combobox-announcer] docs(changeset): Introducing WB Announcer API fo…
marcysutton 28d786c
[combobox-announcer] Move types around for package
marcysutton 98f576a
[combobox-announcer] Add announcer to dropdown dependencies
marcysutton 6e729b1
[combobox-announcer] docs(changeset): Integrates Announcer for value …
marcysutton 23ccbf3
[combobox-announcer] Update pnpm lock
marcysutton 2237028
[combobox-announcer] Update BirthdayPicker tests
marcysutton c803896
[combobox-announcer] Update BirthdayPicker tests
marcysutton 97466df
[combobox-announcer] Remove dropdown-core live region
marcysutton 7cc43f4
[combobox-announcer] Try restoring wb-dev-build-settings
marcysutton 04952a1
[combobox-announcer] Add system types to announcer
marcysutton 62a4e72
[combobox-announcer] Add API to init Announcer on load
marcysutton 8f60715
[combobox-announcer] Hoist uniqueID to top of Announcer
marcysutton 32d09b4
[combobox-announcer] Add debounce wait prop to initializer
marcysutton 8000c04
[combobox-announcer] WIP: rework debounce for combobox
marcysutton 667cb74
[combobox-announcer] Show Announcer in Storybook/MultiSelect
marcysutton 90f0ade
[combobox-announcer] Clean up WIP code
marcysutton fb552e6
[combobox-announcer] Fix clearMessage test w/ debounce
marcysutton 6542633
[combobox-announcer] Clean up unused storybook styles
marcysutton 15ca376
[combobox-announcer-v2] Try restoring BirthdayPicker test
marcysutton 6fd8858
[combobox-announcer-v2] Hide Announcer helper in MultiSelect stories
marcysutton df5d25f
[combobox-announcer-v2] Restore prop in story
marcysutton 28eacc0
[combobox-announcer-v2] Announce filtered items in SingleSelect
marcysutton 30a34dc
[combobox-announcer-v2] Clean up tests
marcysutton bf3193a
[combobox-announcer-v2] PR feedback
marcysutton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-announcer": major | ||
--- | ||
|
||
Introducing WB Announcer API for ARIA Live Regions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@khanacademy/wonder-blocks-dropdown": minor | ||
--- | ||
|
||
Integrates Announcer for value announcements in SingleSelect and MultiSelect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,6 @@ | |
"react": "18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@khanacademy/wb-dev-build-settings": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,7 @@ describe("Announcer class", () => { | |
const waitThreshold = 1000; | ||
|
||
// Act | ||
// The second call will win out in the trailing edge implementation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great job setting up these tests with the initial implementation! Makes it easy to see what's changed with the updated behaviour 😄 |
||
announcer.announce("a thing", "polite", waitThreshold); | ||
announcer.announce("two things", "polite", waitThreshold); | ||
|
||
|
@@ -173,7 +174,7 @@ describe("Announcer class", () => { | |
announcer.dictionary.get(`wbARegion-polite0`)?.element; | ||
|
||
// ASSERT | ||
await expect(targetElement?.textContent).toBe("a thing"); | ||
await expect(targetElement?.textContent).toBe("two things"); | ||
await expect(targetElement2?.textContent).toBe(""); | ||
}); | ||
}); | ||
|
@@ -206,16 +207,12 @@ describe("Announcer class", () => { | |
// Act | ||
announcer.announce("One Fish", "polite", 0); | ||
jest.advanceTimersByTime(5); | ||
announcer.announce("Loud Fish", "assertive", 0); | ||
|
||
expect(screen.getByText("One Fish")).toBeInTheDocument(); | ||
expect(screen.getByText("Loud Fish")).toBeInTheDocument(); | ||
|
||
announcer.clear(); | ||
|
||
// Assert | ||
expect(screen.queryByText("One Fish")).not.toBeInTheDocument(); | ||
expect(screen.queryByText("Loud Fish")).not.toBeInTheDocument(); | ||
}); | ||
|
||
test("handling calls when nothing has been announced", () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/wonder-blocks-announcer/src/__tests__/init-announcer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {screen} from "@testing-library/react"; | ||
import Announcer from "../announcer"; | ||
import {initAnnouncer} from "../init-announcer"; | ||
import {announceMessage} from "../announce-message"; | ||
|
||
describe("Announcer.initAnnouncer", () => { | ||
let announcer: Announcer; | ||
afterEach(() => { | ||
announcer.reset(); | ||
}); | ||
|
||
it("injects the Announcer when called", () => { | ||
// Arrange | ||
announcer = initAnnouncer(); | ||
// Act | ||
const regionWrapper = screen.getByTestId("wbAnnounce"); | ||
// Assert | ||
expect(regionWrapper).toBeInTheDocument(); | ||
}); | ||
|
||
it("only injects one Announcer", () => { | ||
// Arrange | ||
announcer = initAnnouncer(); | ||
announceMessage({message: "A thing"}); | ||
// Act | ||
const regionWrapper = screen.getAllByTestId("wbAnnounce"); | ||
// Assert | ||
expect(regionWrapper.length).toEqual(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/wonder-blocks-announcer/src/__tests__/util/test-utilities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why setTimeout is called twice now? Would be helpful to add a comment here so we remember why!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll add a comment! This was due to the leading edge / trailing edge change in the debounce function. I think the first setTimeout is the initial one for Safari timing, so this configurable one in the test with specific duration/etc. comes second.