Make copy button tooltip appear on click

This commit is contained in:
tidy-dev 2023-10-12 11:06:14 -04:00
parent 4787048bd1
commit 5a3f312ff3
2 changed files with 6 additions and 1 deletions

View file

@ -32,7 +32,7 @@ export class CopyButton extends React.Component<
this.setState({ showCopied: true })
await sleep(1500)
await sleep(2000)
this.setState({ showCopied: false })
}
@ -55,6 +55,7 @@ export class CopyButton extends React.Component<
tooltip={showCopied ? 'Copied!' : ariaLabel}
ariaLabel={ariaLabel}
onClick={this.onCopy}
isToggleTip={true}
>
{this.renderSymbol()}
</Button>

View file

@ -154,6 +154,9 @@ export interface IButtonProps {
/** Specify custom classes for the button's tooltip */
readonly tooltipClassName?: string
/** Whether the button acts as a toggle tip and shows the toolitp on click */
readonly isToggleTip?: boolean
}
/**
@ -222,6 +225,7 @@ export class Button extends React.Component<IButtonProps, {}> {
// Show the tooltip immediately on hover if the button is disabled
delay={disabled ? 0 : undefined}
onlyWhenOverflowed={this.props.onlyShowTooltipWhenOverflowed}
isToggleTip={this.props.isToggleTip}
>
{tooltip}
</Tooltip>