Clear selection state when RESET_BLOCKS action is dispatched#21371
Closed
Clear selection state when RESET_BLOCKS action is dispatched#21371
Conversation
|
Size Change: +1 B Total Size: 884 kB
ℹ️ View Unchanged
|
talldan
commented
Apr 3, 2020
| return { clientId: blockToSelect.clientId }; | ||
| } | ||
| case 'RESET_BLOCKS': | ||
| return {}; |
Contributor
Author
There was a problem hiding this comment.
This is a pretty basic solution at the moment and it doesn't cover that there might be cases where selection should be retained. Maybe if the client id for the currently selected block exists in the blocks array from the RESET_BLOCKS action?
It looks like RESET_BLOCKS is used for synchronizing templates, so that looks like a case where selection could be unexpectedly lost.
However, with multi-selections, trying to retain a selection might cause a situation where selectionStart is retained but selectionEnd is cleared or vice versa.
This was referenced Apr 3, 2020
Contributor
Author
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In #21340 a fix toolbar is used for the new Navigation Menus page that's being developed as an experimental feature.
@draganescu noticed an issue when testing this and changing between menus (#21340 (review)), which seems to be due to block selection state not being reset when
RESET_BLOCKSis dispatched by the new menu selection.How has this been tested?
This can fairly easily be reproduced in the post editor:
wp.data.dispatch('core/block-editor').resetBlocks([]);masterthey're displayed and clicking on the more menu causes the editor to throw an error.)Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: