Best way to focus out automatically on route change ? #756
Replies: 2 comments 3 replies
-
We don't clear focus because Inertia is an SPA, and we maintain state between visits. This is (almost always) desirable. Typically in situations like this I just manually close dropdowns and other similar UI elements...I honestly don't run into this issue often.
That's interesting. Can you give me an example of a library that does this? |
Beta Was this translation helpful? Give feedback.
-
So would you recommend to change the focus the way I currently do it to close the headlessui popover component ? |
Beta Was this translation helpful? Give feedback.
-
I recently had a problem with Headless Popover component maintained by Tailwindcss team.
The popover component need to loose the focus to be able to close/hide.
Usually the router manage the focus for us when the route change, but with inertia the focus doesn't change automatically.
So what I did, was adding a new div to wrap my app and execute :
To be able to focus on the div I added tabindex prop to the wrap div ( tabindex="-1" )
Why Inertia is not focusing out automatically and what is the best way to do this ? My solution feels a bit dirty...
Beta Was this translation helpful? Give feedback.
All reactions