Skip to content

Commit

Permalink
add removeEventListener to removeCopyButton
Browse files Browse the repository at this point in the history
  • Loading branch information
menghif authored and DukeManh committed Mar 26, 2022
1 parent 0f0de60 commit 6920d72
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/web/app/src/components/Posts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,14 @@ function createCopyButton(e: MouseEvent) {
}
}

function removeCopyButton() {
function removeCopyButton(e: MouseEvent) {
const copyButtons = document.querySelectorAll<HTMLDivElement>('.copyCodeBtn');
copyButtons.forEach((elem) => {
elem.parentNode?.removeChild(elem);
const event = e.target;
if (event instanceof HTMLElement && isCodeSnippet(event)) {
event.parentElement?.removeEventListener('mouseleave', removeCopyButton);
}
});
}

Expand Down

0 comments on commit 6920d72

Please sign in to comment.