Skip to content
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

Improve the headings hierarchy in the site editor page #42495

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

- `Autocomplete`: Add heading and fix type for `onReplace` in README. ([#49798](https://github.com/WordPress/gutenberg/pull/49798)).

### Internal

- `Navigation`: Make sure `NavigationMenu` and `NavigationGroup` don't render an empty `aria-labelledby` attribute ([#42495](https://github.com/WordPress/gutenberg/pull/42495)).

## 23.8.0 (2023-04-12)

### Internal
Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/navigation/group/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ export function NavigationGroup( {
{ title }
</GroupTitleUI>
) }
<ul aria-labelledby={ groupTitleId } role="group">
<ul
aria-labelledby={ title ? groupTitleId : undefined }
role="group"
>
{ children }
</ul>
</li>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/navigation/menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function NavigationMenu( props: NavigationMenuProps ) {
) }

<NavigableMenu>
<ul aria-labelledby={ menuTitleId }>
<ul aria-labelledby={ title ? menuTitleId : undefined }>
{ children }
{ search && ! isSearchDebouncing && (
<NavigationSearchNoResultsFound search={ search } />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function DocumentActions() {
<Text
size="body"
className="edit-site-document-actions__title"
as="h1"
as="h2"
>
<VisuallyHidden as="span">
{ sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,14 @@
}
}

.edit-site-document-actions__title-wrapper > h1 {
margin: 0;

// See comment above about min-width
min-width: 0;
}

.edit-site-document-actions__title {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: currentColor;

// See comment above about min-width
min-width: 0;
}

.edit-site-document-actions__secondary-item {
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/list/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function Header( { templateType } ) {

return (
<header className="edit-site-list-header">
<Heading level={ 1 } className="edit-site-list-header__title">
<Heading level={ 2 } className="edit-site-list-header__title">
{ postType.labels?.name }
</Heading>

Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/list/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export default function Table( { templateType } ) {
role="row"
>
<td className="edit-site-list-table-column" role="cell">
<Heading level={ 4 }>
<Heading level={ 3 } size={ 16 }>
<Link
params={ {
postId: template.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ export default function SidebarNavigationScreen( {
{ actions }
</HStack>

<nav className="edit-site-sidebar-navigation-screen__content">
<nav
aria-label={ __( 'Editor' ) }
className="edit-site-sidebar-navigation-screen__content"
>
{ description && (
<p className="edit-site-sidebar-navigation-screen__description">
{ description }
Expand Down
13 changes: 8 additions & 5 deletions packages/edit-site/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@
@import "./components/style-book/style.scss";
@import "./hooks/push-changes-to-global-styles/style.scss";

html #wpadminbar {
body.js #wpadminbar {
display: none;
}

html #wpbody {
body.js #wpbody {
padding-top: 0;
}

// In order to use mix-blend-mode, this element needs to have an explicitly set background-color.
// We scope it to .wp-toolbar to be wp-admin only, to prevent bleed into other implementations.
html.wp-toolbar {
background: $white;
padding-top: 0;
}

body.appearance_page_gutenberg-template-parts,
body.site-editor-php {
body.js.appearance_page_gutenberg-template-parts,
body.js.site-editor-php {
@include wp-admin-reset(".edit-site");
}

Expand All @@ -73,6 +72,10 @@ body.site-editor-php {
top: 0;
}

.no-js & {
min-height: 0;
}

.interface-interface-skeleton {
top: 0;
}
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/specs/site-editor/browser-history.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ test.describe( 'Site editor browser history', () => {
'/wp-admin/site-editor.php?path=%2Fwp_template%2Fall'
);

const title = page.getByRole( 'heading', { level: 1 } );
const header = page.getByRole( 'region', {
name: 'Templates list - Header',
} );
const title = header.getByRole( 'heading', { level: 2 } );
await expect( title ).toHaveText( 'Templates' );
} );
} );
4 changes: 2 additions & 2 deletions test/e2e/specs/site-editor/title.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test.describe( 'Site editor title', () => {
canvas: 'edit',
} );
const title = page.locator(
'role=region[name="Editor top bar"i] >> role=heading[level=1]'
'role=region[name="Editor top bar"i] >> role=heading[level=2]'
);

await expect( title ).toHaveText( 'Editing template: Index' );
Expand All @@ -40,7 +40,7 @@ test.describe( 'Site editor title', () => {
canvas: 'edit',
} );
const title = page.locator(
'role=region[name="Editor top bar"i] >> role=heading[level=1]'
'role=region[name="Editor top bar"i] >> role=heading[level=2]'
);

await expect( title ).toHaveText( 'Editing template part: header' );
Expand Down