Skip to content

Commit

Permalink
fix copy button color bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ogewan committed Sep 27, 2022
1 parent d937f81 commit c9d1054
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/neuroglancer/widget/segment_set_widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@
width: 1.6em;
margin: 3px;
vertical-align: bottom;
}

.segment-copy-pressed {
background-color: rgb(0, 255, 0);
}
8 changes: 2 additions & 6 deletions src/neuroglancer/widget/segment_set_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,6 @@ export class SegmentSetWidget extends RefCounted {

private static addCopyToClipboardEventToButton(
button: HTMLButtonElement, stringCreator: () => string) {
const defaultButtonColor = 'rgb(0, 255, 0)';
const pressedButtonColor = 'rgb(240, 240, 240)';
button.addEventListener('click', function(this: HTMLButtonElement) {
const handleCopy = (e: ClipboardEvent) => {
const {clipboardData} = e;
Expand All @@ -510,11 +508,9 @@ export class SegmentSetWidget extends RefCounted {
}
e.preventDefault();
document.removeEventListener('copy', handleCopy);
this.style.backgroundColor = defaultButtonColor;
this.classList.toggle('segment-copy-pressed', true);
setTimeout(() => {
if (this.style.backgroundColor === defaultButtonColor) {
this.style.backgroundColor = pressedButtonColor;
}
this.classList.toggle('segment-copy-pressed', false);
}, 300);
};
document.addEventListener('copy', handleCopy);
Expand Down

0 comments on commit c9d1054

Please sign in to comment.