-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Keep the focus in the block navigation when user's last interaction was with the block navigation #22524
Conversation
…as with the block navigation
One last issue here is that the block is not possible to select using the block navigation. This is an issue on the master branch too though, so we could probably address it in another PR. |
Size Change: +619 B (0%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that in other similar use-cases ( replaceBlocks
action), instead of having an auto-focus mode, we rely on a flag in the action to not update the selection. can't tell which approach is better but seems like some consistency would be good?
It's not clear to me what this mode is for since in the same dropdown if you click a block, the idea is to go focus the block which kind of defeats the purpose of the mode. Is it an indication that having more descriptive actions is maybe a better approach? |
The navigator should be a summarized view of the block hierarchy. They way things are going, considering we plan to manipulate all the document's structure from the navigator, we need both things to work, that is transferring the selection to the editor and keeping the selection in the navigator. I would explicitly add an action, "Go to block", that selects the block from the editor, instead of having a mode that auto selects the block when I click on it in the navigator. The focus problem is that when I work in the context of the summarized view of the block hierarchy I do not want to be transferred to the editor unexpectedly. I do wonder if the editor needs anything changed, or if the navigator itself has to manage its focus more thoroughly. |
@youknowriad @draganescu The culprit is the following excerpt from the gutenberg/packages/block-editor/src/components/block-list/block-wrapper.js Lines 126 to 130 in e8b9de4
As you can see, it will "steal" the focus when the block becomes selected. In order to move along without an autofocus mode, we would either need to:
|
@draganescu it's the other way around :-) that mode prevents the editor from performing it's default action (selecting the block) |
Yes, I know but unless I'm wrong it could be solved by saying "duplicate but don't select"? |
Right, that's correct. My assumption was that we want to select after duplicating though - that's what happens when you duplicate from the editor. I wonder, maybe it's time to take a step back and consider separating the selection in the navigator from the selection in the editor? At least on that experimental screen. |
Does the selection in the navigation serve other purposes than just an "indication" about the block selected block in the editor? |
It's not obvious to me at the moment. In the post editor, one of the purposes the navigator serves is to make it easy to reach deeply nested blocks. You click on the navigator item and the block becomes selected. In the experimental navigation screen it is different. Even though we use the same navigator component, we customized it so that it no longer selects a related block on click - instead it makes it possible to quickly edit the link text. Let's put this PR on hold for now - I'll start a discussion in the original issue #22089 |
It seems like we're moving away from navigator items being editable by default which also solves the underlying issue behind this PR. It may re-emerge at some point, but for now this PR may be safely closed. |
Description
PR #22427 introduced an experimental ellipsis menu to the block navigation on the experimental nav management screen. Unfortunately, duplicating a block using that menu transfers the focus back to the editor area. To provide the best possible experience for users using mostly their keyboards, we should do the following:
.focus()
the new item in the block navigation..focus()
the new block in the editor area.I've been thinking about possible ways of approaching this issue and concluded that the editor must know whether or not it is allowed to grab the focus. This PR introduces the new editor state variable called
isAutoFocusEnabled
. The editor will onlyfocus()
on the new block ifisAutoFocusEnabled === true
.How has this been tested?
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: