Skip to content
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

Announcer: Part 1 #2362

Open
wants to merge 27 commits into
base: announcer
Choose a base branch
from
Open

Announcer: Part 1 #2362

wants to merge 27 commits into from

Conversation

marcysutton
Copy link
Member

@marcysutton marcysutton commented Nov 15, 2024

The initial implementation for a live region component! I'm getting this draft PR up so I can test with the remote URL.

Jira Issue: https://khanacademy.atlassian.net/browse/WB-1768

Outstanding questions/work areas:

  • Testing in more ATs, particularly in webapp and on mobile devices.
  • More integration with React. I did a bit of React integration to use Testing Library in the way they want you to, but the real deal will be experimenting with it in Wonder Blocks and webapp.

Copy link

changeset-bot bot commented Nov 15, 2024

🦋 Changeset detected

Latest commit: 32774c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@khanacademy/wonder-blocks-announcer Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Nov 15, 2024

Size Change: +1.7 kB (+1.69%)

Total Size: 103 kB

Filename Size Change
packages/wonder-blocks-announcer/dist/es/index.js 1.7 kB +1.7 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.78 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.77 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.04 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 3.44 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 18.2 kB
packages/wonder-blocks-form/dist/es/index.js 6.28 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.76 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3 kB
packages/wonder-blocks-icon/dist/es/index.js 871 B
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.28 kB
packages/wonder-blocks-modal/dist/es/index.js 5.36 kB
packages/wonder-blocks-pill/dist/es/index.js 1.65 kB
packages/wonder-blocks-popover/dist/es/index.js 4.87 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.3 kB
packages/wonder-blocks-switch/dist/es/index.js 1.94 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.74 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.36 kB
packages/wonder-blocks-toolbar/dist/es/index.js 827 B
packages/wonder-blocks-tooltip/dist/es/index.js 7.08 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Nov 15, 2024

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-kghtbkjdwu.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 370
Tests with visual changes 1
Total stories 504
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 370

@marcysutton marcysutton marked this pull request as ready for review November 20, 2024 21:28
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Nov 20, 2024

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/thirty-ducks-type.md, __docs__/wonder-blocks-announcer/announcer.stories.tsx, packages/wonder-blocks-announcer/package.json, packages/wonder-blocks-announcer/tsconfig-build.json, static/sb-styles/preview.css, packages/wonder-blocks-announcer/src/Announcer.ts, packages/wonder-blocks-announcer/src/announce-message.ts, packages/wonder-blocks-announcer/src/clear-messages.ts, packages/wonder-blocks-announcer/src/index.ts, packages/wonder-blocks-announcer/types/Announcer.types.ts, packages/wonder-blocks-announcer/src/__tests__/Announcer.test.ts, packages/wonder-blocks-announcer/src/__tests__/announce-message.test.tsx, packages/wonder-blocks-announcer/src/__tests__/clear-messages.test.tsx, packages/wonder-blocks-announcer/src/util/dom.ts, packages/wonder-blocks-announcer/src/util/util.ts, packages/wonder-blocks-announcer/src/__tests__/components/announce-message-button.tsx, packages/wonder-blocks-announcer/src/__tests__/util/dom.test.ts, packages/wonder-blocks-announcer/src/__tests__/util/util.ts

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

@khan-actions-bot khan-actions-bot requested a review from a team November 20, 2024 21:28
Copy link
Contributor

github-actions bot commented Nov 20, 2024

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (b6fe9ab) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2362"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2362

Copy link
Member

@jandrade jandrade left a comment

Choose a reason for hiding this comment

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

This is looking really good! Giving my initial review with some suggestions on how to structure the files to be more consistent with the rest of the repo and asking some questions to get a bit more context on certain parts. This is great progress 👏

packages/wonder-blocks-announcer/CHANGELOG.md Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/index.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/index.ts Outdated Show resolved Hide resolved
Comment on lines 34 to 36
setTimeout(() => {
return announcer?.announce(message, level, removalDelay);
}, 100);
Copy link
Member

Choose a reason for hiding this comment

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

question: Is there a specific reason why we need to use this timeout? I wonder if there's another way to handle this case, but I don't think I have full context on that.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was for Safari and VoiceOver, but I can play around with it again to see if we really need it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this does seem important for Safari in particular! I made it configurable so it can be manipulated at runtime if necessary (especially for tests).

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up removing this with the move to async! It wasn't needed in my testing for Safari/Voiceover.

packages/wonder-blocks-announcer/src/index.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/index.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/index.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/index.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/index.ts Show resolved Hide resolved
@khan-actions-bot khan-actions-bot requested a review from a team November 22, 2024 17:28
Copy link
Member

@beaesguerra beaesguerra left a comment

Choose a reason for hiding this comment

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

Great work so far Marcy! Left some feedback and questions 😄

timeoutDelay: {
control: "number",
type: "number",
description: "(milliseconds)",
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if there's a way for us to use the function docs for the storybook docs! Normally we're able to get the prop docs automatically from setting component in this block, though this is different since these docs are for functions rather than components!

cc: @jandrade in case you have come across similar things before!

packages/wonder-blocks-announcer/src/send-message.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/types/Announcer.types.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/Announcer.ts Outdated Show resolved Hide resolved
}
/**
* Recover in the event regions get lost
* This happens in Storybook when saving a file:
Copy link
Member

Choose a reason for hiding this comment

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

Would this also happen in webapp with HMR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, potentially! I'll do some testing on it.

*/
createRegionWrapper(level: PolitenessLevel) {
const wrapper = document.createElement("div");
wrapper.id = `wbAWrap-${level}`;
Copy link
Member

Choose a reason for hiding this comment

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

For curiosity, does the A in wbAWrap stand for Announcer or assertive? I'm assuming "Announcer", but just wanted to double check since we also have aIndex and pIndex!

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it was a prefix for Wonder Blocks Announcer! The full id for these ends up like: wbAWrap-polite. It's pretty arbitrary though, so I could change it. I debated on whether to keep these wrapper elements at all, as they aren't really being used for anything.

packages/wonder-blocks-announcer/src/Announcer.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-announcer/src/Announcer.ts Outdated Show resolved Hide resolved
@khan-actions-bot khan-actions-bot requested a review from a team November 22, 2024 21:56
Why didn't Prettier do this automatically? I do not know...
1. Keeps announce from being called too frequently. We can play with the timeout duration.
2. Makes the returned IDREF more reliable in a browser.
1. Keeps announce from being called too frequently. We can play with the timeout duration.
2. Makes the returned IDREF more reliable in a browser.
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