@@ -1,5 +1,5 @@
|
||||
---
|
||||
'@backstage/core-components': minor
|
||||
'@backstage/core-components': patch
|
||||
---
|
||||
|
||||
Improve accessibility for CopyTextButton
|
||||
|
||||
@@ -44,6 +44,6 @@ export const LongerTooltipDelay = () => (
|
||||
export const WithAriaLabel = () => (
|
||||
<CopyTextButton
|
||||
text="The text to copy to clipboard"
|
||||
ariaLabel="This is an aria label"
|
||||
aria-label="This is an aria label"
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('<CopyTextButton />', () => {
|
||||
it('aria-label', async () => {
|
||||
const { getByLabelText } = await renderInTestApp(
|
||||
<TestApiProvider apis={apis}>
|
||||
<CopyTextButton {...props} ariaLabel="text for aria-label" />
|
||||
<CopyTextButton {...props} aria-label="text for aria-label" />
|
||||
</TestApiProvider>,
|
||||
);
|
||||
expect(getByLabelText('text for aria-label')).toBeInTheDocument();
|
||||
|
||||
@@ -50,7 +50,7 @@ export interface CopyTextButtonProps {
|
||||
}
|
||||
|
||||
type LabelledCopyTextButtonProps = CopyTextButtonProps & {
|
||||
ariaLabel?: string;
|
||||
'aria-label'?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ type LabelledCopyTextButtonProps = CopyTextButtonProps & {
|
||||
* ```
|
||||
* <CopyTextButton
|
||||
* text="My text that I want to be copied to the clipboard"
|
||||
* ariaLabel="Accessible label for this button" />
|
||||
* arial-label="Accessible label for this button" />
|
||||
* ```
|
||||
*/
|
||||
export function CopyTextButton(props: LabelledCopyTextButtonProps) {
|
||||
@@ -77,7 +77,7 @@ export function CopyTextButton(props: LabelledCopyTextButtonProps) {
|
||||
text,
|
||||
tooltipDelay = 1000,
|
||||
tooltipText = 'Text copied to clipboard',
|
||||
ariaLabel = 'Copy text',
|
||||
'aria-label': ariaLabel = 'Copy text',
|
||||
} = props;
|
||||
const errorApi = useApi(errorApiRef);
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
Reference in New Issue
Block a user