Skip to content
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

Preserve selection when switching block editor tabs #18239

draganescu opened this issue Nov 1, 2019 · 4 comments


Copy link

@draganescu draganescu commented Nov 1, 2019

Describe the bug
This is probably an intended feature, but when switching tabs in the editor sidebar between document and block, the current block selection is lost.

The problem is easily recoverable on desktop, but it presents an almost empty screen on mobile, looking like an error.

To reproduce
Steps to reproduce the behavior:

  1. Selet a block
  2. Show the sidebar
  3. Click on Document
  4. Click on Block
  5. No block is selected so this panel is now empty

Expected behavior
I expect the selection to be preserved because there is nothing I did to it by fiddling with the sidebar's tabs.


This comment has been minimized.

Copy link
Contributor Author

@draganescu draganescu commented Nov 1, 2019

@mapk @jasmussen since fixing this is a matter of simply not clearing the selection anymore, by removing a single call to clearSelectedBlock() in the openDocumentSettings() handler of the Document Tab click, it seems to not be a technical need, so I wonder why is this interaction like this?

@jorgefilipecosta is there any technical reason to clear the block selection?


This comment has been minimized.

Copy link
Contributor Author

@draganescu draganescu commented Nov 5, 2019

@mtias and @jasmussen for posterity, here is a sum up of what we discussed:

  • we need to have the blocks selected when we switch back to the block tab in the inspector. I propose that instead of building a mechanism to restore selection, we simply don't clear it anymore.

The argument is this:

  • the main reason deselection happens is because clicking the document tab is conceptually similar to clicking on the canvas, hence deselecting everything.
  • the other reason deselection happens is because the tabs are similar to breadcrumbs and clicking on the document is similar to moving selection to one level left in the breadcrumb bar.

My opinion is that:

  • while the [ document tab == canvas ] principle is real, implementing it results in a bad experience. The worst of it is on small screens where switching inspector tabs results in an empty page, if returning to the block tab. While the principle is true, the reality of it should be that we do what is best for the user.
  • the breadcrumbs reason doesn't hold because we have tabs today and tabs are not hierarchical when they're on the same level. Simply put switching inspector tabs should not do anything to the document, including clearing the block selection.

Another thing that popped up in discussion is being future proof: we might have a new "Site" tab very soon when we start seeing signs of FSE in the editor. I think this is yet even more of a reason to stop clearing block selection. If at some point in the future we will require moving the selection in the document because we switched tabs, only then it is a good time to implement a mechanism for remembering previous selection states and applying them.

Implementing such a mechanism today will most likely require a refactor when block areas and whatnot shall appear.

The final thing is that the inspector is contextual and I also disagree with that, the inspector tabs are contextual not the entire inspector. Similar to this, desktop software only have contextual toolbars or sidebars, never changing things you can't see (such as the block tab in our case).

One example, props to @noisysocks , which behaves similar is Apple Pages where switching inspector tabs, even to document, does not clear any selection in the document:



This comment has been minimized.

Copy link

@mapk mapk commented Nov 12, 2019

As another example, seems to clear the selection when clicking another tab but returns the selection when the tab is clicked back again.

blocs 2019-11-11 18_35_11

If the selection in Gutenberg didn't clear, what would happen if I have a block selected and clicked the Document tab? Would I just see the Document settings, but the block would still remain selected? Looking at the example from @noisysocks, it may not be a bad decision.


This comment has been minimized.

Copy link
Contributor Author

@draganescu draganescu commented Nov 13, 2019

Yes @mapk that's what I propose: when we click the Document tab we leave the current selected block be selected. That's all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.