-
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
Move HeadinglevelDropdown to its own component #46003
Conversation
Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
Size Change: -752 B (0%) Total Size: 1.4 MB
ℹ️ View Unchanged
|
packages/block-editor/src/components/block-tag-selection/index.js
Outdated
Show resolved
Hide resolved
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
import { useCanEditEntity } from '../utils/hooks'; | ||
|
||
export default function PostTitleEdit( { | ||
attributes: { level, textAlign, isLink, rel, linkTarget }, | ||
setAttributes, | ||
context: { postType, postId, queryId }, | ||
} ) { | ||
const TagName = 0 === level ? 'p' : 'h' + level; |
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 noticed that this code seems to have been adapted for allowing the post title to be a paragraph, but I don't remember this being implemented? It was only implemented for the site title.
Because of the discussions in this issue #30549
I have removed the partial support for p tag.
This comment was marked as outdated.
This comment was marked as outdated.
Another reason for adding a new component for this is that developers would like to choose which tags are available, either via theme.json or via a filter. |
packages/block-editor/src/components/block-heading-level-dropdown/heading-level-icon.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-heading-level-dropdown/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-heading-level-dropdown/README.md
Show resolved
Hide resolved
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, @carolinan! The changes test really well for me.
If there are no blockers for native/mobile, then let's merge this. cc @geriux
And thank you for the review. |
@WordPress/gutenberg-design I feel that this is ready to be merged, but I also think it could be improved if the text "Heading 1" etc, was always visible to the right of the icon inside the dropdown and not only as a tooltip, as discussed in #50402 |
I think it seems a bit redundant to have both. |
I did not mean using both tooltip and permanently visible text. I meant the permanent text is an improvement over the tooltip, which covers the other options because of its position. |
Right, I mean having "H1" and "Heading 1" right next to it seems a bit redundant. I think the tooltip is performing as expected, if you move to another item, the tooltip moves with it. Is the tooltip only necessary because we don't have visible text, like in other toolbar menus? |
* Add a tag selection component for the block toolbar (replaces HeadingLevelDropdown) * Update index.php * update fixtures * Update CSS class, replace sprintf in the label with the tag name * Add visible tag name to the drop down, add placeholder icon * Update README.md * Try to fix issue with the deprecation * Update CHANGELOG.md * Simplify and rename component * Try reverting fixture changes * And again... * Update Query title to use the new component * Update Comments title * Update Site title with paragraph exception * Update Heading block * Update rich-text.test.js * Block Heading Dropdown - Add support for mobile (WordPress#47967) * Text changes for a native file and e2e test spec * Use the updated headingLevel icons * Update prop names * Add 'options' property to type definiton --------- Co-authored-by: Gerardo Pacheco <[email protected]> Co-authored-by: George Mamadashvili <[email protected]>
I'd kindly disagree. The tooltip is an usability problem now that the dropdown is vertical, as reported in #55927 and #50402. I don't think keeping both the icon and the visible text is redundant. Instead, it bring sin best of both worlds: a visual hint and an universally understandable visible text. It's not uncommon for many big applications around to display both an icon and visible text. I would also like to remind that icon-only buttons have inherent usability and accessibility problems. Their usage shoudl be limited to only cases where there's not enough space to use visible text. |
What?
Updated May 24.
The HeadingLevelDropdown is a toolbar option used to choose between H1-H6 in the heading block, comments title, query title, and post title. The files are in the heading block, and the other blocks import them.
The site title has its own similar option, and it adds a paragraph to the selection.
This PR moves the HeadingLevelDropdown from the heading block to its own component.
Fixes #45743
Why?
The same code is reused in multiple blocks.
How?
Creates a new component that can be consistently reused in multiple blocks.
Testing Instructions
Screenshots or screencast
Heading block, before (The H1 is hovered over):
After, using the updated icons (The H6 is hovered over):