-
Notifications
You must be signed in to change notification settings - Fork 23
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
Modal, Alert: label modal with title contents #3702
Merged
Merged
Conversation
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
RasmusKjeldgaard
force-pushed
the
enhancement/3677-modal-a11y
branch
from
November 12, 2024 16:26
dd12ade
to
0347343
Compare
RasmusKjeldgaard
changed the title
Modal, Alert: Label modal with title contents
Modal, Alert: label modal with title contents
Nov 19, 2024
libs/designsystem/modal/src/modal-wrapper/compact/modal-compact-wrapper.component.ts
Outdated
Show resolved
Hide resolved
apps/cookbook/src/app/examples/modal-example/compact-example/modal-compact-example.component.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Jakob Engelbrecht <jakob@basher.dk>
jakobe
previously approved these changes
Nov 22, 2024
libs/designsystem/modal/src/modal-wrapper/compact/modal-compact-wrapper.component.ts
Outdated
Show resolved
Hide resolved
jakobe
reviewed
Dec 10, 2024
libs/designsystem/modal/src/modal-wrapper/modal-wrapper.component.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Jakob Engelbrecht <jakob@basher.dk>
jakobe
approved these changes
Dec 10, 2024
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.
🥳
Fuzzy3
added a commit
that referenced
this pull request
Dec 11, 2024
Co-authored-by: Jakob Engelbrecht <jakob@basher.dk> Co-authored-by: Søren Oest Balmer <oestbalmer@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue does this PR close?
This PR closes #3677 closes #3679
What is the new behavior?
Background
For all our different types of modals, we need a way to label them for assistive tech. We want to remove this burden from developers, so they do not have to re-visit every modal and apply a label.
One solution would be to use aria-labelledby as recommended for modals with visible title bars, but since IDs are scoped to the shadow root, this is not an option with ion-modal. The dialog element is within the modals shadow-root, while the title provided by us is in the light-dom, so any ID ref for the title is undefined in the dialogs tree. This is a general limitation ("feature") when working with shadow roots, and I have created a small example of this here: https://codepen.io/rasmooose/pen/dyxwWLa
Therefore we need to instead use the aria-label attribute and ensure that it is updated whenever the title changes. The most common use-case for a changing title is routed modal flows, where the same modal instance is reused for multiple views, but this could also simply be some async content.
We now sync the title to the
ion-modal
dialog elements aria-label. It is done via the modal wrapper and message state (empty state) component when used inside modals.This ensures that a title is set across the different types of modals and also the alert.
A mutation observer or title setters are used where relevant to react to title changes and update the label of ancestor modals.
The only identified edge-case not supported by this pattern is compact modals without an empty state - in this case developers need to set the aria-label attribute themselves.
Does this PR introduce a breaking change?
Are there any additional context?
Checklist:
The following tasks should be carried out in sequence in order to follow the process of contributing correctly.
Reminders
Review
When the pull request has been approved it will be merged to
develop
by Team Kirby.