-
Notifications
You must be signed in to change notification settings - Fork 115
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
[WIP] Support prop to announce banner when it is shown #2583
Conversation
|
} | ||
} | ||
} | ||
this.observer = new IntersectionObserver(callback, options) |
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.
Looked into IntersectionObserver
because it was mentioned in #2576 (comment).
I am expecting this to detect when the Banner's visibility changes from hidden to being visible.
Close review would be appreciated.
7882d28
to
89f1c73
Compare
|
bc05bc6
to
ecb54a9
Compare
26f8f67
to
aeb1eba
Compare
3021350
to
8c0e6d1
Compare
cb0eec6
to
4f6ee15
Compare
<p class="Banner-title" data-target="<%= catalyst_target(field: "titleText") %>"><%= content %></p> | ||
<% if @description %> | ||
<p><%= @description %></p> | ||
<span data-target="<%= catalyst_target(field: "contentToAnnounce") %>"> |
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.
The dismiss button should not be announced.
// eslint-disable-next-line import/no-unresolved | ||
import '@primer/live-region-element/define' |
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.
How to fix this? Also, I noticed we don't need to make this call in other custom elements since it's exported as part of the index. Wonder if we should do the same for live-region
?
9702766
to
2c0b982
Compare
|
||
assert_selector("#wrapper", visible: :visible) | ||
assert_equal page.evaluate_script("document.querySelector('live-region').shadowRoot.querySelector('[aria-live=\"polite\"]').innerText.trim()"), "Hello." | ||
end |
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.
I want to add a test for when Primer::Alpha::Banner
is dynamically injected. How should I set this up?
This is a proof of concept, and has a pre-req to ship:
<live-region>
should be part of the page layout of the consuming application. We probably want a PVC wrapper for this likePrimer::Alpha::LiveRegion
, and have guidance that nudges consumers to add it to their page layout.What are you trying to accomplish?
When banners are shown async to communicate feedback, we should either be focusing or announcing the banner content to draw attention to it. Read more at Banner docs.
This is a proof of concept to support a
announce_on_show
prop that, when set, announces the banner content upon it's visibility being updated by the consumer.This should support a live region announcement being made across the following scenarios:
announce_on_show: true
. (Test written ✅ )announce_on_show: true
is set. (Test written ✅ )announce_on_show: true
. (Needs test ❌ Any tips for how to go about dynamically injecting a view component in our system tests? )IMPORTANT 🔈
Dynamically injected live region attributes don't work reliably so we cannot just set
aria-live
on the Banner and expect it to announce when the Banner appears. See Staff only: Challenges with dynamically injected live region.This approach depends on hooking into live-region-element which is ideally already part of the page layout. As called out in the beginning, there is pre-req work necessary to support live-region. Consumer needs to add this to their page layout.
Integration
This depends on
<live-region>
to be part of the page layout of the repos it is called in.List the issues that this change affects.
Relates to: https://github.com/github/accessibility/issues/5649
Risk Assessment
Merge checklist
Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.