-
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
Keep Lock button it in the toolbar until unmounted #57229
Conversation
Size Change: -99 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
Flaky tests detected in 7123d3a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7277638447
|
Probably best to hear from @WordPress/gutenberg-design folks for feedback on the newly proposed logic |
|
||
const shouldHideBlockLockUI = |
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 think there's a use-case where folks don't want people to be able to unlock and I believe there's a setting for that, so we need to make sure that this setting is still supported.
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.
The behavior on trunk is to not show the Lock Icon at all if canLockBlocks
is false. So, the block is locked, but the user has no indicator. I'll match the behavior on trunk for now, then follow up with another PR that displays the lock icon without it opening a modal.
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.
Implemented the idea on showing a disabled lock icon for locked blocks when the user cannot edit it: #57274
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.
@jeryj, that's how I initially implemented the toolbar button but then reverted the change based on suggestion - #39566 (comment).
This seems like a good change to me. |
…ntil unmounted. If the block lock button has been shown, we don't want to remove it from the toolbar until the toolbar is rendered again without it. Removing it beforehand can cause focus loss issues, such as when unlocking the block from the modal. It needs to return focus from whence it came, and to do that, we need to leave the button in the toolbar.
7ec8d46
to
7123d3a
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.
Thank you, @jeryj!
The changes look good to me and work as expected ✅
Fixes #51447 and #57139
Alternative to #57185
If the block lock button has been shown, we don't want to remove it from the toolbar until the toolbar is rendered again without it. Removing it beforehand can cause focus loss issues, such as when unlocking the block from the modal. It needs to return focus from whence it came, and to do that, we need to leave the button in the toolbar.
What?
If the Lock Button has rendered, force it to stay in the toolbar as a "lock" action button until the component is unmounted.
Clicking the "Unlocked" icon would trigger the lock modal again. Again, this would only show after unlocking the block. It would not show for all toolbars.
Why?
How?
hasLockButtonShown
ref set totrue
if the Lock Button is rendered in the toolbar.hasLockButtonShown
and the block becomes unlocked while the toolbar is showing, preserve the button with an unlock icon to open the lock modal.Testing Instructions
Repeat above steps starting from an unlocked block:
Repeat both of the above from the Top Toolbar
Testing Instructions for Keyboard
Repeat above using Keyboard
Screenshots or screencast
Screen.Recording.2023-12-19.at.10.52.44.AM.mov