-
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
Block Editor: Maintain selection when multi-selection toggled #16336
Conversation
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes on my documentation attempts here (cc @ellatrix):
- I assumed
BLOCK_SELECTION_EMPTY_OBJECT
was 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_STATE
are 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
start
andend
as an object, but could only find that we referenceclientId
on it. Are there other properties, or could it just be replaced with a direct reference to theclientId
?
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.
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.