-
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 warning: add ellipsis menu and convert to classic block #7741
Conversation
Very nice work, I pushed some polish: I also removed the styles for the contents of the navibable menu. Can I kindly ask you to take a look at the more menu and perhaps steal a bit from there? We have some components for menuy groups, menu labels and even menu items. If we reuse those, we get the visual styles, as well as their accessibility for free. |
dc17ec8
to
cae4b87
Compare
0d92752
to
2008867
Compare
The overall style was moved into another PR, and the code here updated to use the 'more menu' as mentioned by Joen. I've added a slight CSS tweak to better vertically align the ellipsis button |
97682ed
to
e60a13f
Compare
Very cool, what's the status of this? Does it need a wider Gutenberg review? Do you need anything from me to ship this? |
e60a13f
to
800283c
Compare
7da5418
to
f774a4b
Compare
Adds an ellipsis dropdown menu so additional actions can be added outside of the primary buttons Note this just adds the capability for additional actions, but doesn’t actually include any
Makes use of the new ellipsis menu to present the sa,e convert to blocks option along with a convert to classic block
The menu is slightly vertically off-centred when on full screen desktop. This moves it a bit while still looking ok on mobile
f774a4b
to
41c6a45
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.
Looking good, just left some small notes.
@@ -30,6 +30,10 @@ function BlockInvalidWarning( { convertToHTML, convertToBlocks } ) { | |||
</Button> | |||
), | |||
] } | |||
hiddenActions={ [ |
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.
Could this be secondaryActions (to match the "primaryActions" prop)?
{ hiddenActions && ( | ||
<div className="editor-warning__hidden"> | ||
<Dropdown | ||
className="edit-post-more-menu" |
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 edit-post-*
className seems useless right? (they don't follow our guidelines neither)
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.
It's the same class used in https://github.com/WordPress/gutenberg/blob/master/edit-post/components/header/more-menu/index.js, making the ellipsis vertical rather than horizontal. I can file a separate issue if that also needs changing to match the guidelines?
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 don't think we should rely on classnames styled in other components. We should aim to reuse components instead of classnames instead.
So two options:
- I'm fine duplicating the styles (if not too much) and using the right classnames here
editor-warning__*
- Creating a generic component with these styles but in that case, this component should be meaningful. Maybe it could be a prop of
Dropdown
instead?
Matches primary actions
CSS is minimal, and can be refactored into a new component later
@youknowriad thanks for looking. All good points. For the purpose of this PR I've copied the appropriate styles to this component - it's pretty minimal. While looking at the CSS I noticed the original component has what appears to be dead CSS as well as problems on mobile (that only affect the other component). I'll investigate that separately and if it makes sense, refactor with this component while fixing any problems. |
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.
LGTM 👍 Nice work
This shouldn't have been merged.
|
Good catch @aduth I missed that :( |
Description
Add the ability for a block warning message to show a list of additional actions that are hidden behind a dropdown ellipsis menu. This will be used to expand the options available to a user when an invalid block is detected.
The 'convert to blocks' option is copied into this menu, along with a new 'convert to classic block' option. This matches the mockup in #7604. More options will be added in future PRs
How has this been tested?
Extra unit tests have been added to verify when the ellipsis menu appears.
npm run test warning
Types of changes
A non-breaking new feature is added to an existing component. The
Warning
component is used by:BlockInvalidWarning
BlockCrashWarning
To test
BlockInvalidWarning
:</p>
to trigger the block validation messageTo test
BlockCrashWarning
:wp.blocks.registerBlockType( 'myplugin/mr-crashy', { title: 'Mr. Crashy', category: 'common', icon: 'warning', edit() { throw new Error(); }, save() { return ''; } } );
Mr Crashy
block to a postChecklist: