-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Previously-focused block steals focus from blocks added by the main inserter #28932
Comments
It looks like the |
Yeah, I think so. By default, when a dialog is closed, the focus should return to the element that spawned it when it is closed. The inserter is seeing that as the paragraph in this case. I think you are on the right track but am not sure specifically how to implement that without looking into it further - that PR was the first time I had worked with useFocusReturn 😓 |
…by the main inserter Workaround for WordPress/gutenberg#28932. To be reverted once we get a fix from GB core.
* Trigger E2E tests * Try to find elements that did not receive focus after being inserted by the main inserter Workaround for WordPress/gutenberg#28932. To be reverted once we get a fix from GB core. * Fix typos in comment * Foce-select the image block so that the contextual settings open for it * More comment typo fixes * Also click the image in the gb page editor spec Co-authored-by: Marcelo Serpa <81248+fullofcaffeine@users.noreply.github.com>
Looks like this issue is back in v10.1.0-rc.1. We have an E2E test to catch it, but it seems like it didn't make it to v10.1 (planned for v10.2). Any idea what could be causing this regression? @youknowriad @ockham @fullofcaffeine @rafaelgalani |
Interestingly, that E2E test wouldn't catch it as the focus stealing happens on mobile viewport only (Unless those specs are set to run on all viewports which I'm not aware of). I've confirmed it by running that test on a
|
Description
This is somewhat of a corner case and I could only reproduce with the paragraph block being the first block on the page. When that's the case, and if has been given focus and some text, and if you try adding other blocks after it, you'll notice that the newly-inserted block won't get focus, the focus will stay (or get back?) to the paragraph input.
Step-by-step reproduction instructions
I should note that this doesn't seem to happen if the block you add after the paragraph also is a text input. For example, the "Quote" block. Then it seems to get the focus, as expected.
Expected behavior
The last-inserted block should be given and keep the focus. It should be automatically selected after insertion from the main inserter.
Actual behavior
The focus/selection goes back to the paragraph's text input.
Screenshots or screen recording (optional)
Peek.2021-02-10.19-43.mp4
Code snippet (optional)
Not a snippet, but I did try bisecting between GB 9.8.4 and 9.9.1 (the version where I first experienced this issue) and git pointed me to this merge commit as the culprit: #28438.
WordPress information
Device information
The text was updated successfully, but these errors were encountered: