Skip to content
Draft
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
9 changes: 9 additions & 0 deletions src/copy-to-clipboard/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ export default function InternalCopyToClipboard({
}, [copyErrorText]);

const baseProps = getBaseProps(restProps);

// Extract data-* attributes to forward to the inner button for analytics support.
const dataAttributes: Record<string, string> = {};
Object.keys(restProps).forEach(key => {
if (key.match(/^data-/)) {
dataAttributes[key] = (restProps as Record<string, string>)[key];
}
});
const onClick = () => {
if (!navigator.clipboard) {
// The clipboard API is not available in insecure contexts.
Expand Down Expand Up @@ -87,6 +95,7 @@ export default function InternalCopyToClipboard({

const button = (
<InternalButton
{...dataAttributes}
ariaLabel={copyButtonAriaLabel ?? copyButtonText}
iconName="copy"
variant={triggerVariant}
Expand Down
Loading