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 is restored to some previously focused element when Dialog component unmounts on a page (Next.js) #2509

Closed
Sartonon opened this issue May 23, 2023 · 4 comments
Assignees

Comments

@Sartonon
Copy link

Sartonon commented May 23, 2023

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.7.14

What browser are you using?

Chrome

Reproduction URL

Tried to reproduce this in a simple environment but couldn't.

Describe your issue

On @headlessui/react v.1.7.13 and onwards when changing page and Dialog component unmounts on a page (closed state) focus is restored to some previously focused element (header menu item).

Problem is also fixed if I just add unmount={false} to the Transition component that our menu is using.

I think it is related to this PR: #2326

@thecrypticace
Copy link
Contributor

Hey! Is there any reproduction you can provide? I've tried to reproduce this and can't. The described situation itself seems strange to me which may be why:

  1. The dialog is controlled by a button in a shared layout
  2. The dialog itself is NOT in said shared layout but in a component on a particular page
  3. You've opened the dialog, closed the dialog, and THEN changed pages? (this I'm not quite clear on)
  4. This change of pages is what caused the dialog to unmount
  5. As a result of this you see a focused button in the shared header / layout piece

Any insight you can give here would be much appreciated!

@RobinMalfait RobinMalfait self-assigned this Aug 11, 2023
@RobinMalfait
Copy link
Member

Hey!

Going to close this issue for now since it's been a while and no reproduction repo has been attached since.

If you are still running into this issue then I would recommend to install the insiders version to see if this issue is still occurring for you since we did some improvements to the Transition component:

  • npm install @headlessui/react@insiders

If you are still running into this issue when you are using the insiders version, then I would suggest to open a new issue with a minimal reproduction repo attached so that we can take a look at what's going on. Once we have that information, then I'm more than happy to debug and see what's going on.

Thanks!

@Sartonon
Copy link
Author

Hello!

I totally missed the previous comment and I had already forgotten this issue because I was using the workaround unmount={false}.

Unfortunately I'm not working on the project where this issue was present so I can't test the insider version.

@Oskii2311
Copy link

Hello,
we have a similar problem. Here is a thread with reproduction codesandbox ->
#2650
@RobinMalfait

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

4 participants