Avoid focus loss on switching tabs - #1859
Conversation
bcotrim
left a comment
There was a problem hiding this comment.
Have you considered changing the TabPanel key to selectedSite.id?
I think it would also fix the issue without needing the isFirstRender lastChangeWasUser logic.
Unrelated observation: While testing keyboard navigation, I noticed that navigating to the AI Assistant tab moves focus to the input. This is pre-existing behavior from trunk, but it feels unexpected when navigating via keyboard. Might be worth a separate issue?
I did and this approach would be simpler but would it not affect setting the tabs like this, for example? studio/src/hooks/use-site-details.tsx Line 200 in 3348f90 |
You are right, on |
gcsecsey
left a comment
There was a problem hiding this comment.
The changes LGTM. I was also thinking about potential simplifications, thanks for the explanation above Kat for why the useEffect and the refs are needed.
Functionally, this works great:
CleanShot.2025-10-09.at.12.29.07.mp4
Yeah I spent some time dancing around it yesterday but could not find something simpler to make sure there is no regressions 😅 |
Related issues
Proposed Changes
This PR ensures that we don't lose focus when we use the keyboard navigation when switching between tabs.
Testing Instructions
Pre-merge Checklist