Skip to content

Commit 99abbd8

Browse files
committed
Added safety removal for event listener
Fixed modal text overflowing
1 parent 611b7de commit 99abbd8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/webapp/app/components/code/CodeBlock.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,12 @@ export const CodeBlock = forwardRef<HTMLDivElement, CodeBlockProps>(
228228
document.documentElement.style.userSelect = "";
229229
el.style.userSelect = "";
230230
document.removeEventListener("mouseup", restore);
231+
window.removeEventListener("blur", restore);
231232
restoreRef.current = null;
232233
};
233234
restoreRef.current = restore;
234-
document.addEventListener("mouseup", restore);
235+
document.addEventListener("mouseup", restore, { once: true });
236+
window.addEventListener("blur", restore, { once: true });
235237
}, []);
236238

237239
useEffect(() => {
@@ -413,7 +415,7 @@ export const CodeBlock = forwardRef<HTMLDivElement, CodeBlockProps>(
413415
</Button>
414416
</DialogHeader>
415417

416-
<div onMouseDown={handleCodeMouseDown}>
418+
<div onMouseDown={handleCodeMouseDown} className="overflow-auto px-3 py-3 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600">
417419
{shouldHighlight ? (
418420
<HighlightCode
419421
theme={theme}

0 commit comments

Comments
 (0)