Skip to content

List View: Enhance list view to display heading level with title - #70136

Closed
Infinite-Null wants to merge 3 commits into
WordPress:trunkfrom
Infinite-Null:add-heading-level
Closed

Infinite-Null wants to merge 3 commits into
WordPress:trunkfrom
Infinite-Null:add-heading-level

Conversation

@Infinite-Null

@Infinite-Null Infinite-Null commented May 15, 2025 •

Copy link
Copy Markdown
Contributor

What?

This PR enhances the List View by displaying the heading level (H1, H2, etc.) alongside the heading title, making it easier to identify and navigate the heading hierarchy.
Closes #54631

Why?

List View doesn't visually indicate heading levels, making it difficult for users to understand the document structure without selecting each heading individually.

Testing Instructions for Keyboard

Testing Instructions for Keyboard

  1. Create a new post
  2. Add a heading to the post
  3. Open list view and verify whether the title of the heading is appended with heading level or not, like H1, H2, etc.

Screenshot:

Before After
image image

@Infinite-Null Infinite-Null changed the title Enhance list view to display heading level with title List View: Enhance list view to display heading level with title May 15, 2025
@Infinite-Null
Infinite-Null marked this pull request as ready for review May 16, 2025 05:16
@Infinite-Null
Infinite-Null requested a review from ellatrix as a code owner May 16, 2025 05:16
@github-actions

github-actions Bot commented May 16, 2025 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Infinite-Null <ankitkumarshah@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: paaljoachim <paaljoachim@git.wordpress.org>
Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: karmatosed <karmatosed@git.wordpress.org>
Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org>
Co-authored-by: mtias <matveb@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>
Co-authored-by: BluePraise <magaliechetrit@git.wordpress.org>
Co-authored-by: aristath <aristath@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Feature] List View Menu item in the top toolbar to select blocks from a list of links. labels May 16, 2025

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Additional design feedback may be needed, but from a code perspective, let's avoid adding block-specific processing to the useBlockDisplayTitle hook.

We should be able to change the label by adding __experimentalLabel field. Example:

__experimentalLabel( attributes, { context } ) {

@t-hamano t-hamano added the Needs Design Feedback Needs general design feedback. label May 21, 2025
@Infinite-Null

Copy link
Copy Markdown
Contributor Author

Hi @t-hamano, Thank you for the feedback. I have made the necessary changes. Please review it at your convenience.

@Infinite-Null
Infinite-Null requested a review from t-hamano May 23, 2025 06:22
@t-hamano

Copy link
Copy Markdown
Contributor

Thanks for the update! I think the approach itself is good.

Another important thing is that we always need to take localization into account. In the current implementation, the order is fixed, like {Heading Level}: {Heading Content}, so it is not appropriate for RTL languages.

We should be able to do it like this:

if ( context === 'list-view' ) {
	const listViewTitle =
		customName || ( hasContent ? content : __( 'Heading' ) );
	return sprintf(
		/* translators: list view text. 1: heading level. 2: heading content. */
		__( '%1$s: %2$s' ),
		`H${ level }`,
		listViewTitle
	);
}

Also, I think the code itself is mostly good, but I'd like to hear what the designers think about this change. @WordPress/gutenberg-design

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems fine, let's wait for design feedback.

@t-hamano
t-hamano requested a review from a team June 4, 2025 09:08
@paaljoachim

Copy link
Copy Markdown
Contributor

Great! Thank you for working on this @Infinite-Null

To me it seems to do the job it needs to do. It looks identical with selecting a Heading block.

@fabiankaegy

Copy link
Copy Markdown
Member

@Infinite-Null @karmatosed actually just added some designs for this in #42181

I think instead of adding the heading level as raw text we should instead dynamically swap out the icon to use the heading level icons as @karmatosed showed there :)

Let me know if you have any questions / concerns about this.

@fabiankaegy fabiankaegy linked an issue Jun 5, 2025 that may be closed by this pull request
@t-hamano

t-hamano commented Jun 5, 2025

Copy link
Copy Markdown
Contributor

we should instead dynamically swap out the icon to use the heading level icons

This is technically possible, but there are two points to be aware of:

  • I think it's necessary to convey the same information to screen readers. Screen readers should announce list view items properly, both in heading and non-heading blocks.
  • This icon is retrieved by the useBlockDisplayInformation hook. This hook is based on clientId only and does not support dynamic icon changing based on attributes. A new API or hook might be needed to avoid hard-coding.

@jasmussen

Copy link
Copy Markdown
Contributor

Much delayed design feedback: the motivation is right, but I believe I saw a separate PR that, instead of adding a prefix to the list item title, it changes the icon, so instead of showing the bookmark heading icon, it would show the heading level icon. 1-6 here:

image

I'd prefer that personally, since it would be more of an agnostic treatment of the heading level display, whereas adding a prefix feels like a one-off solution made just for headings.

Thanks so much for the PR, and for contributing, I hope this is fair.

@t-hamano

t-hamano commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Sorry for the late reply!

The Heading block seems to render icons depending on the level now. I think this is related to the variation added to the Heading block in #73823.

image

I'd like to close this PR, but thanks for your efforts!

@t-hamano t-hamano closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] List View Menu item in the top toolbar to select blocks from a list of links. Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List View: consider showing heading level and ensure aria label shows heading level Show Heading level in the sidebar

5 participants