-
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: move selection state from RichText to the store #14640
Conversation
8f68912
to
d118977
Compare
d69e964
to
a9cccaa
Compare
d5deacd
to
c08c0b5
Compare
@@ -97,34 +97,6 @@ const tabThroughBlockToolbar = async () => { | |||
); | |||
await expect( isFocusedRightAlignmentControl ).toBe( true ); | |||
|
|||
// Tab to focus on the 'Bold' formatting button |
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.
Reason why these are no longer expected: the formatting toolbar is only available one the rich text field has selection. The buttons are useless otherwise. In master, they are useless as well, but they display because there is lingering local selection state, so the toolbar thinks that the rich text field is selected. If you select the block for the first time in master, there will also be no formatting buttons. See #13598.
}; | ||
} | ||
|
||
// Ensures that only one RichText component can be focused. |
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.
This is no longer needed as the selection state is stored in block-editor
and there can be no two identifiers at the same time.
2d20ef9
to
800953a
Compare
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 will give it a spin and see how it works.
It might fix #7463 as well :)
In comparison to the It seems like the changes proposed should open possibilities to finally resolve #7463 which we tried to tackle a few times but it was extremely difficult to detect blur event when implementation of |
Description
Fixes #11616.
Blocks #11005 and #12002. Blocks making RichText a controlled component.
This is an attempt to move local
RichText
selection state toblock-editor
store.RichText
would have the following props:selectionStart
: the selection start offset, similar to thetextarea
attrubute.selectionEnd
: the selection end offset, similar to thetextarea
attrubute.onSelectionChange
: the function that will be called when the selection changes.Within blocks, this state is provided by context. Nothing changes for block authors.
In the
block-editor
store, the selection state will now include a rich text identifier and offset in addition to the block client ID.Why?
How has this been tested?
Screenshots
Types of changes
Checklist: