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

Navigation Link: Improve accessibility by removing non-interactive tooltips #68628

Merged
Merged
58 changes: 27 additions & 31 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
TextControl,
TextareaControl,
ToolbarButton,
Tooltip,
ToolbarGroup,
} from '@wordpress/components';
import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
Expand Down Expand Up @@ -490,10 +489,6 @@ export default function NavigationLinkEdit( {
const placeholderText = `(${
isInvalid ? __( 'Invalid' ) : __( 'Draft' )
})`;
const tooltipText =
isInvalid || isDraft
? __( 'This item has been deleted, or is a draft' )
: __( 'This item is missing a link' );

return (
<>
Expand Down Expand Up @@ -532,11 +527,9 @@ export default function NavigationLinkEdit( {
<a className={ classes }>
{ /* eslint-enable */ }
{ ! url ? (
<div className="wp-block-navigation-link__placeholder-text">
<Tooltip text={ tooltipText }>
<span>{ missingText }</span>
</Tooltip>
</div>
<span className="wp-block-navigation-link__placeholder-text">
{ missingText }
</span>
) : (
<>
{ ! isInvalid &&
Expand Down Expand Up @@ -578,27 +571,30 @@ export default function NavigationLinkEdit( {
{ ( isInvalid ||
isDraft ||
isLabelFieldFocused ) && (
<div className="wp-block-navigation-link__placeholder-text wp-block-navigation-link__label">
<Tooltip text={ tooltipText }>
<span
aria-label={ __(
'Navigation link text'
) }
>
{
// Some attributes are stored in an escaped form. It's a legacy issue.
// Ideally they would be stored in a raw, unescaped form.
// Unescape is used here to "recover" the escaped characters
// so they display without encoding.
// See `updateAttributes` for more details.
`${ decodeEntities( label ) } ${
isInvalid || isDraft
? placeholderText
: ''
}`.trim()
}
</span>
</Tooltip>
<div
className={ clsx(
'wp-block-navigation-link__placeholder-text',
'wp-block-navigation-link__label',
{
'is-invalid': isInvalid,
'is-draft': isDraft,
}
) }
>
<span>
{
// Some attributes are stored in an escaped form. It's a legacy issue.
// Ideally they would be stored in a raw, unescaped form.
// Unescape is used here to "recover" the escaped characters
// so they display without encoding.
// See `updateAttributes` for more details.
`${ decodeEntities( label ) } ${
isInvalid || isDraft
? placeholderText
: ''
}`.trim()
}
</span>
</div>
) }
</>
Expand Down
12 changes: 11 additions & 1 deletion packages/block-library/src/navigation-link/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@
margin-bottom: $grid-unit-20;
margin-left: $grid-unit-20;
}

.wp-block-navigation-link__placeholder-text {
&.is-invalid {
--wp-underline-color: var(--wp--preset--color--vivid-red);
}

&.is-draft {
--wp-underline-color: var(--wp--preset--color--luminous-vivid-amber);
}
}
}

.wp-block-navigation-link__invalid-item {
Expand All @@ -80,7 +90,7 @@
background-image: none !important;

// Draw a wavy underline.
.wp-block-navigation-link__placeholder-text span {
.wp-block-navigation-link__placeholder-text {
$blur: 10%;
$width: 6%;
$stop1: 30%;
Expand Down
Loading