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
Focusing a ref inside tabs needs to wait, why? #61164
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +12 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
1 similar comment
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
Just as the nature of React, I don't think we can assume that everything in a given subtree will be mounted synchronously, especially when it involves components that were authored by other people. I think the generic strategy still applies here, where you listen for the mount of a subtree that you do control (sandbox example). |
What?
Moving the search control inside the tab makes the ref be set after the parent component of the tab is mounted. It shouldn't be the case, but it appears that tabs render last.
Why?
We tried in #61108 to move the search control into the inserter tabs and keep the search control auto focus behavior. In the mean time this route is not what makes most sense, but the problem still remains:
requestAnimationFrame
?If a component steps out of normal rendering timing via timeouts, effects or other async stuff maybe emiting a ready event when it’s all done is needed?
In the screenshot below the search control should be focused, like it is on trunk.