Skip to content

Commit 68b2def

Browse files
authored
fix: disable copy in textInputWithCopyButton when button is disabled (#3419)
* feat: add ability to disable copy in textInputWithCopyButton * fix: use disabled prop to fix ctrl-c bug * fix: remove unnecessary comment * fix: add disabled in destructured props
1 parent fdbfc4d commit 68b2def

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/components/text-input-with-copy-button/TextInputWithCopyButton.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,16 @@ class TextInputWithCopyButton extends React.PureComponent<Props, State> {
159159
};
160160

161161
handleCopyEvent = (event: SyntheticEvent<>) => {
162-
this.animateCopyButton();
162+
const { disabled, onCopySuccess } = this.props;
163+
164+
if (disabled) {
165+
event.preventDefault();
166+
} else {
167+
this.animateCopyButton();
163168

164-
const { onCopySuccess } = this.props;
165-
if (onCopySuccess) {
166-
onCopySuccess(event);
169+
if (onCopySuccess) {
170+
onCopySuccess(event);
171+
}
167172
}
168173
};
169174

0 commit comments

Comments
 (0)