Skip to content

Commit 7a06fd9

Browse files
committed
fix allow passing aria label to link
1 parent 1ed5078 commit 7a06fd9

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

components/link/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ interface LinkProps {
104104
kind?: string;
105105
placeholder?: string;
106106
className?: string;
107+
ariaLabel?: string;
107108
}
108109

109110
/*
@@ -123,6 +124,7 @@ export const Link: FC<LinkProps> = ({
123124
kind = '',
124125
placeholder = __('Link text ...', '10up-block-components'),
125126
className = undefined,
127+
ariaLabel = undefined,
126128
...rest
127129
}) => {
128130
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
@@ -155,7 +157,7 @@ export const Link: FC<LinkProps> = ({
155157
className={clsx('tenup-block-components-link__label', className)}
156158
value={value}
157159
onChange={onTextChange}
158-
aria-label={__('Link text', '10up-block-components')}
160+
aria-label={ariaLabel || value || __('Link text', '10up-block-components')}
159161
placeholder={placeholder}
160162
__unstablePastePlainText
161163
allowedFormats={[]}

components/link/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const BlockEdit = (props) => {
3737
onLinkRemove={ handleLinkRemove }
3838
className='example-classname'
3939
placeholder='Enter Link Text here...'
40+
ariaLabel='Read more about our services'
4041
/>
4142
</div>
4243
)
@@ -59,4 +60,5 @@ The `<RichText>` node will only render when BlockEdit is selected.
5960
| `kind` | `string` | `""` | Page or Post |
6061
| `placeholder` | `string` | `Link text ...` | Text visible before actual value is inserted |
6162
| `className` | `string` | `undefined` | html class to be applied to the anchor element |
63+
| `ariaLabel` | `string` | `undefined` | Custom aria-label for accessibility. Defaults to the link text (value) if not provided |
6264
| `...rest` | `object` | `{}` | pass through any additional props to the RichText component used for the link element |

0 commit comments

Comments
 (0)