Add prop to disable block selection clearer in BlockList#44517
Add prop to disable block selection clearer in BlockList#44517
Conversation
|
Size Change: +89 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
talldan
left a comment
There was a problem hiding this comment.
This kind of change does always pose a maintenance issue. There's nothing to stop this setting becoming accidentally broken because it's unused in first-party code. I would suggest adding tests, though it may be challenging to test this kind of thing.
It's also hard to know whether an editor with this setting might have some weird side effects, either now or in the future.
In terms of the API, I think it might be better exposed as an editor setting to avoid adding extra props to BlockList. Something along the lines of clearBlockSelection: false (and it would have a true default).
It could also be made an __experimental setting to start with until there has been more chance to test it. That means there's more of an option to remove the setting if you change your mind.
packages/block-editor/src/components/block-selection-clearer/index.js
Outdated
Show resolved
Hide resolved
bc76f22 to
be68c99
Compare
|
Thanks for the feedback, @talldan!
While this is true, this is a relatively straightforward disabling of an event that (as far as I can tell) tends to be more specific to handling of deselection around iframes. There weren't any tests around block selection clearing yet, and not a ton around
Great idea! Also prefixed this with |
|
Hi @talldan could you take another look at this when you have time? |
|
Hi @talldan do you have time to take another look at this PR? |
talldan
left a comment
There was a problem hiding this comment.
Sorry for the delays reviewing. This looks good now, thanks for addressing the feedback!
What?
This PR adds a prop to allow disabling of the block selection clearing.
I'm open to other ways of handling this, but this seems like the most minimal and non-invasive way to handle this without affecting existing editors.
Fixes #44508
Why?
This can be useful for consumers wanting to use the block editor who don't necessarily want to deselect block elements and lose the contextual toolbar when editing.
In WooCommerce, we're working on a rich text editor which should always show a toolbar. Currently this isn't always possible due to deselection:
How?
Testing Instructions
disableBlockSelectionClearerprop:Screenshots or screencast