Skip to content

Commit 727b033

Browse files
committed
Improve the link preview accessibility and labels.
1 parent 058cc37 commit 727b033

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

packages/block-editor/src/components/link-control/link-preview.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import classnames from 'classnames';
66
/**
77
* WordPress dependencies
88
*/
9-
import { __, sprintf } from '@wordpress/i18n';
9+
import { __ } from '@wordpress/i18n';
1010
import {
1111
Button,
1212
ExternalLink,
@@ -79,7 +79,8 @@ export default function LinkPreview( {
7979

8080
return (
8181
<div
82-
aria-label={ __( 'Currently selected' ) }
82+
role="group"
83+
aria-label={ __( 'Manage link' ) }
8384
className={ classnames( 'block-editor-link-control__search-item', {
8485
'is-current': true,
8586
'is-rich': hasRichData,
@@ -90,7 +91,14 @@ export default function LinkPreview( {
9091
} ) }
9192
>
9293
<div className="block-editor-link-control__search-item-top">
93-
<span className="block-editor-link-control__search-item-header">
94+
<span
95+
className="block-editor-link-control__search-item-header"
96+
role="figure"
97+
aria-label={
98+
/* translators: Accessibility text for the link preview when editing a link. */
99+
__( 'Link information' )
100+
}
101+
>
94102
<span
95103
className={ classnames(
96104
'block-editor-link-control__search-item-icon',
@@ -132,25 +140,24 @@ export default function LinkPreview( {
132140
label={ __( 'Edit link' ) }
133141
onClick={ onEditClick }
134142
size="compact"
143+
showTooltip={ ! showIconLabels }
135144
/>
136145
{ hasUnlinkControl && (
137146
<Button
138147
icon={ linkOff }
139148
label={ __( 'Remove link' ) }
140149
onClick={ onRemove }
141150
size="compact"
151+
showTooltip={ ! showIconLabels }
142152
/>
143153
) }
144154
<Button
145155
icon={ copySmall }
146-
label={ sprintf(
147-
// Translators: %s is a placeholder for the link URL and an optional colon, (if a Link URL is present).
148-
__( 'Copy link%s' ), // Ends up looking like "Copy link: https://example.com".
149-
isEmptyURL || showIconLabels ? '' : ': ' + value.url
150-
) }
156+
label={ __( 'Copy link' ) }
151157
ref={ ref }
152158
disabled={ isEmptyURL }
153159
size="compact"
160+
showTooltip={ ! showIconLabels }
154161
/>
155162
<ViewerSlot fillProps={ value } />
156163
</div>

0 commit comments

Comments
 (0)