Skip to content

Commit

Permalink
fix(Copy): avoid label text mismatch (#6428)
Browse files Browse the repository at this point in the history
* chore: prettier

* fix(Copy): avoid label text mismatch

* chore: prettier

Co-authored-by: Alessandra Davila <aledavila@ibm.com>
Co-authored-by: TJ Egan <tw15egan@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 17, 2020
1 parent 40e112b commit 177a6bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
top: 1.2rem;
left: 50%;

&:focus {
border: 2px solid $support-01;
}

&::before {
@include box-shadow;
@include type-style('body-short-01');
Expand Down Expand Up @@ -71,6 +75,10 @@
}

// TODO: deprecate above styles
.#{$prefix}--copy {
font-size: 0;
}

.#{$prefix}--copy-btn {
@include reset;

Expand Down Expand Up @@ -121,6 +129,7 @@
&.#{$prefix}--copy-btn--animating.#{$prefix}--copy-btn--fade-out::before,
&.#{$prefix}--copy-btn--animating.#{$prefix}--copy-btn--fade-out
.#{$prefix}--copy-btn__feedback {
// https://github.com/stylelint/stylelint/issues/2363
animation: $duration--fast-02 motion(standard, productive) hide-feedback;
}

Expand Down
8 changes: 6 additions & 2 deletions packages/react/src/components/Copy/Copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function Copy({
...other
}) {
const [animation, setAnimation] = useState('');
const classNames = classnames(className, {
const classNames = classnames(className, `${prefix}--copy`, {
[`${prefix}--copy-btn--animating`]: animation,
[`${prefix}--copy-btn--${animation}`]: animation,
});
Expand Down Expand Up @@ -64,9 +64,13 @@ export default function Copy({
])}
{...other}
aria-live="polite"
aria-label={animation ? feedback : other['aria-label']}>
aria-label={
(!children && (animation ? feedback : other['aria-label'])) || null
}>
{children}
{animation ? feedback : other['aria-label']}
<span
aria-hidden="true"
className={`${prefix}--assistive-text ${prefix}--copy-btn__feedback`}>
{feedback}
</span>
Expand Down

0 comments on commit 177a6bd

Please sign in to comment.