-
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: Add block lock setting #39566
Conversation
@senadir, I plan to add a block support flag in separate PR. |
@@ -157,6 +158,7 @@ export const SETTINGS_DEFAULTS = { | |||
__experimentalBlockPatternCategories: [], | |||
__experimentalSpotlightEntityBlocks: [], | |||
__experimentalGenerateAnchors: false, | |||
__experimentalCanLockBlocks: true, |
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.
Do we want to ship this new setting as experimental?
Size Change: +57 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
Nice one. I may be doing something wrong (I'm lazy and pasting the filters in functions.php on my active theme), but I can't get it to quite lock these things. So I'm commenting on your questions.
There's some nuance to this question which makes it non trivial. My instinct would be that disabling the code editor just because a single block is locked, would not feel intuitive. But there might be a good separate conversation to have, to allow themes to disable the code editor altogether. It's the mix state: locked and unlocked blocks, that's tricky.
I like to think that the icon serves an informative purpose, even when it isn't clickable, and therefore deserves full contrast (i.e. not graying). |
Try "Pages" my snippet disables new locking UI there 😄
Sure, this can be addressed in follow-up PR(s). I will remove opacity for the icon. Thanks for the feedback, Joen. |
Nice! The full contrast lock works really well: I'm not sure we need the focus outline on the icon when the menu is inaccessible 🤔 Maybe it could be similar to the "Save draft" button in the top bar where there's a visible focus indicator when the button is active but not when the button is inactive: |
Nice! I think we should not render the lock icon if the user cannot interact with it. It'd keep things leaner and on parity with the current experience. |
e5d60cd
to
dcd311a
Compare
Thanks for the feedback, everyone. I've updated the rendering logic for the toolbar icon. |
It would be nice if we could ship this and #39568 alongside the UI in the 12.9 release. |
dcd311a
to
ee59544
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 tested this and it looks good to me!
* Register settings * Use setting * Use aria-disabled * No opacity * Don't render toolbar icon if user can't interact Author: George Mamadashvili <[email protected]> Date: Thu Mar 24 12:47:37 2022 +0400
Hi. I don't know if I am posting in the correct place.
The documentation is just so not clear! (As me too) What I am trying: Can somebody help me listing+disabling all blocks editing? |
Hi, @GregoireSailland The block-locking reference in this PR only affects block movement and removing features. You can't control block settings visibility using this feature. Have you tried the Resources:
|
@Mamaduka I ended up doing this: _ I need now to not preserve lock state when saving... (restore like before locking all) |
@Mamaduka Sorry to bother you :)
But when blocks are saved, they keep the lock state |
@GregoireSailland, Do you mind creating a new issue? Since our current discussion isn't related to this PR. P.S. I'm out of the office for a week, but I will be happy to have a look at this issue when I'm back. |
Thanks. |
The discussions might be better suited for these typo of questions - https://github.com/WordPress/gutenberg/discussions/new/choose. |
Thanks if anyone interested I opened a discution related here: |
What?
Part of #29864.
PR introduces new
__experimentalCanLockBlocks
block editor setting.Why?
Currently, a new Block Locking UI is available for every user. The new settings will allow developers/site admins to enable/disable UI based on specific conditions (seen in the example below).
How?
The setting value can be set on the server-side using the
block_editor_settings_all
filter; it's then used to hide the Options menu item and disable the "Lock" button in the block toolbar.Questions
Testing Instructions
Screenshots or screencast