Block Editor: Maintain selection when multi-selection toggled#16336
Block Editor: Maintain selection when multi-selection toggled#16336
Conversation
jorgefilipecosta
left a comment
There was a problem hiding this comment.
Worked well on my tests and the change makes sense 👍
|
@jorgefilipecosta In some final review of the changes, I was looking at the initial state object and it occurred to me that if the intent with "toggling" selection is to allow/disallow multi-selection, we should cancel any multi-selection ( |
| @@ -699,6 +699,27 @@ export function isCaretWithinFormattedText( state = false, action ) { | |||
| } | |||
|
|
|||
| const BLOCK_SELECTION_EMPTY_OBJECT = {}; | |||
There was a problem hiding this comment.
A few notes on my documentation attempts here (cc @ellatrix):
- I assumed
BLOCK_SELECTION_EMPTY_OBJECTwas used here to allow for some strict equality checks in selectors, though I could not find any place we actually do this. The tests also pass if its use below inBLOCK_SELECTION_INITIAL_STATEare replaced with new objects. Can you clarify what purpose this value serves? - And on that note, for what reason does it need to be an object? I had planned to document
startandendas an object, but could only find that we referenceclientIdon it. Are there other properties, or could it just be replaced with a direct reference to theclientId?
There was a problem hiding this comment.
Don't we do any strict equality checks in the reducer? Perhaps I removed that later on, so this wouldn't be needed any longer.
The selection object can also include the rich text identifier and caret position, if a rich text instance is selected.
|
@jorgefilipecosta @aduth What is still needed to get this merged? |
|
Up again here :) should we close or land this PR? |
|
It appears this is no longer an issue. I cannot reproduce the original steps. I suspect it was fixed separately as a result of #17467. |
Extracted from #15927
Previously: #14640 (comment)
This pull request seeks to revise the behavior of the selection reducer to persist selected block through (multi-)selection toggling. Without these changes, an image will become unselected when resizing it, or as in #15927, the Columns block would become unselected when resizing columns.
Testing Instructions:
Verify that resizing an image does not unselect the block.