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

Modal, Alert: label modal with title contents #3702

Merged
merged 46 commits into from
Dec 10, 2024

Conversation

RasmusKjeldgaard
Copy link
Collaborator

@RasmusKjeldgaard RasmusKjeldgaard commented Nov 11, 2024

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?

  • Yes
  • No

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

  • Make sure you have implemented tests following the guidelines in: "The good: Test".
  • Make sure you have updated the cookbook with examples and showcases (for bug fixes, enhancements & new components).

Review

  • Determine if your changes are a fix, feature or breaking-change, and add the matching label to your PR. If it is tooling, dependency updates or similar, add ignore-for-release.
  • Do a self-review.
  • Request that the changes are code-reviewed
  • Request that the changes are UX reviewed (only necessary if your PR introduces visual changes)

When the pull request has been approved it will be merged to develop by Team Kirby.

@RasmusKjeldgaard RasmusKjeldgaard force-pushed the enhancement/3677-modal-a11y branch from dd12ade to 0347343 Compare November 12, 2024 16:26
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y November 12, 2024 16:31 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y November 14, 2024 08:58 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y November 19, 2024 11:18 Inactive
@RasmusKjeldgaard RasmusKjeldgaard changed the title Modal, Alert: Label modal with title contents Modal, Alert: label modal with title contents Nov 19, 2024
Co-authored-by: Jakob Engelbrecht <jakob@basher.dk>
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y November 22, 2024 10:06 Inactive
jakobe
jakobe previously approved these changes Nov 22, 2024
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y November 22, 2024 10:09 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y December 3, 2024 10:30 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y December 3, 2024 10:34 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y December 5, 2024 09:22 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y December 5, 2024 09:39 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y December 5, 2024 09:45 Inactive
@github-actions github-actions bot temporarily deployed to pr-3677-modal-a11y December 10, 2024 15:41 Inactive
Co-authored-by: Jakob Engelbrecht <jakob@basher.dk>
@RasmusKjeldgaard RasmusKjeldgaard enabled auto-merge (squash) December 10, 2024 16:03
Copy link
Collaborator

@jakobe jakobe left a comment

Choose a reason for hiding this comment

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

🥳

@RasmusKjeldgaard RasmusKjeldgaard merged commit d4cb8be into develop Dec 10, 2024
12 checks passed
@RasmusKjeldgaard RasmusKjeldgaard deleted the enhancement/3677-modal-a11y branch December 10, 2024 16:19
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
Labels
feature Add this PR to the changelog as a feature
Projects
None yet
3 participants