-
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
List View: Display lock status #40088
Conversation
Size Change: +99 B (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
@jasmussen, I just pushed a minor update to use a button with an icon instead of SVG. It should also fix the color inheritance issue + adds label. Since the icon does nothing, maybe we should choose a different method to communicate that block is locked. @alexstine, any suggestions? |
Could it open the same lock/unlock modal? |
Sure, but Block Options is right next to the lock status icon, and users could also use it to unlock. |
{ isLocked && ( | ||
<TreeGridCell | ||
className="block-editor-list-view-block__lock-cell" | ||
aria-selected={ !! isSelected } | ||
> | ||
{ ( { ref, tabIndex, onFocus } ) => ( | ||
<Button | ||
disabled | ||
ref={ ref } | ||
tabIndex={ tabIndex } | ||
onFocus={ onFocus } | ||
icon={ lock } | ||
label={ sprintf( | ||
/* translators: %s: block name */ | ||
__( 'Locked %s' ), | ||
blockInformation.title | ||
) } | ||
/> | ||
) } | ||
</TreeGridCell> | ||
) } |
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 it can be simpler than making it a button in a cell, the cells should only really be used for focusable elements. An alternative would be to add it to the ListViewBlockSelectButton component as an Icon
, after the anchor (https://github.com/WordPress/gutenberg/blob/trunk/packages/block-editor/src/components/list-view/block-select-button.js). That component's children are laid out using flexbox, so hopefully the icon can be made to justify/align itself at the end. I think you'd hopefully then be able to use the similar CSS to the block icon to make it switch between black and white on block selection.
The other part that I think should be tackled is announcing the locked status to screenreaders.
I was having a look to see how the selected block is announced so that this could be done in the same way, but I can't see it in the code. There might have been a regression.
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.
Moving status icon into ListViewBlockSelectButton
makes sense.
The other part that I think should be tackled is announcing the locked status to screenreaders.
You're right. Currently, locked blocks aren't announced. I am adding this issue to my to-do list. Thanks for checking and catching the issue, @talldan.
Moved lock status icon into Now it's just a wrapper span with an icon in it. I'm happy to work on the locked block announcements as a follow-up or in this PR. |
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.
Works great for me! Thanks @Mamaduka 🚀
Thanks for testing, @critterverse. I will wait for @talldan's code review for my recent changes and then merge it. |
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.
Works great. I still think it'd be worth considering adding some info for screenreaders about the locked status. It can be a follow-up.
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.
Code looks sane but need to figure this out for screen readers in follow-up. Maybe change the value of the aria-label? Just an idea to think about.
@alexstine, now that element isn't focusable, will aria-label work? @talldan, you mentioned making lock status part of the selected block announcement. The only announcement in the List View component is in Can you point me to the correct file, and I will do a follow-up. |
@Mamaduka I was thinking just making it part of the label, as Alex says. There used to be some visually hidden text in the gutenberg/packages/block-editor/src/components/list-view/block-select-button.js Lines 94 to 98 in dc9e9d2
I think you can do exactly the same visually hidden implementation for locked status. |
Thank you, @alexstine. So it's better to communicate lock status via The hidden text variant could be something like this: { isLocked && (
<VisuallyHidden>
{ __( '(locked block)' ) }
</VisuallyHidden>
) } |
@Mamaduka The link has |
Thanks again, @alexstine. I will start the new PR tomorrow. We can try and find the best option to include a label there. |
Ah, sorry for the bad advice, I'm a little outdated after recent changes to the component. Thanks for pointing us in the right direction, Alex! |
What?
Resolves #40070.
Display block lock status in the "List View."
Why?
Lock status makes it easier to see which blocks are locked.
How?
Adds new
TreeGridCell
only displayed when the block is locked.P.S. I noticed that when one block is locked, the other block's content cells get different widths.
Testing Instructions
Screenshots or screencast