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

Focus Outline Appears on Modal Close Button After Pressing Esc Key #1503

Open
2 tasks
zubairzahid94 opened this issue Oct 21, 2024 · 0 comments
Open
2 tasks

Comments

@zubairzahid94
Copy link

Description:

  • I have searched the Issues to see if this UI control has already been reported
  • I have tested the latest version

Steps to reproduce:

  1. Go to a Modal component with the dismissible prop set to true.
  2. Open the modal, then press the Esc key to close the modal.
  3. Reopen the modal and observe the close (cross) button.

Current behavior:
After reopening the modal by pressing the Esc key, the close (cross) button displays a visible focus outline. This behavior appears to be a default focus style, which can be distracting in some UI designs.

Expected behavior:
The close (cross) button should not retain focus or show any outline after reopening the modal via the Esc key. The button should only display a focus outline when clicked or navigated to via keyboard controls, to provide a smoother user experience.

Context:
This UI issue is mostly about improving user experience and visual design. It happens across multiple browsers, screen sizes, and is consistent with modals that use the dismissible prop.

Solution:
I resolved this issue by applying a custom class to the entire modal and using custom CSS to remove the focus outline on the close button. Specifically, I added the class focus:outline-none to the modal, which effectively prevents the focus outline from appearing when the modal is reopened after pressing the Esc key. This provides a cleaner and more visually appealing interface.
If needed, I can provide a code sandbox or minimal reproduction for better clarity.

image

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

No branches or pull requests

1 participant