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

🚀 feat(Dialog): improve accessibility #849

Merged
merged 5 commits into from
Nov 21, 2024

Conversation

leonardo-gympass
Copy link
Contributor

@leonardo-gympass leonardo-gympass commented Nov 18, 2024

JIRA Issue

Description 📄

Add react-focus-lock library to @gympass/yoga package, with this library the following features were added to Dialog, BottomSheet and Drawer components:

  • Create a focus trap inside the Dialog when it is opened, that way the user can't move the focus away from the Dialog.
  • Focus on the last active element when the Dialog is closed.
  • Focus on the first programmatic focusable element when the Dialog is opened.

Add props role="dialog" and aria-modal=true to Dialog component.
Add closeLabel prop to be used as the aria-label from close button.

Platforms 📲

  • Web
  • Mobile

Type of change 🔍

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested? 🧪

[Enter the tips to test this PR]

  • Unit Test
  • Snapshot Test

Checklist: 🔍

  • My code follows the contribution guide of this project Contributing Guide
  • Layout matches design prototype: FIGMA
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Screenshots 📸

Default behavior

Screen.Recording.2024-11-18.at.16.42.58.mov

New screen reader behavior

Screen.Recording.2024-11-18.at.16.41.37.mov

Current screen reader behavior

Screen.Recording.2024-11-18.at.16.52.46.mov

Copy link

sonarqubecloud bot commented Nov 18, 2024

@leonardo-gympass leonardo-gympass changed the title feat(Dialog): improve accessibility 🚀 feat(Dialog): improve accessibility Nov 18, 2024
@leonardo-gympass leonardo-gympass marked this pull request as ready for review November 18, 2024 19:55
lockProps={lockProps}
returnFocus
disabled={!isOpen}
className={className}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the use of className here? Can this allow style customization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The purpose was to maintain compatibility with the current API of the component to avoid any side effects. Currently all props are passed to the Dialog, I kept this behavior in the lockProps, but the className is not accepted in this prop, which is why I had to create this exception.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand, I think we can keep this prop for now for safety and in the future we make it more restricted, no problem.

@flavia-moraes flavia-moraes merged commit c1f3f47 into master Nov 21, 2024
4 checks passed
@flavia-moraes flavia-moraes deleted the feat/add-focus-trap-to-dialog branch November 21, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants