From 067eb4e4d15fbc10bfe379e2d5c1ed4fa227ed28 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Mon, 8 Jan 2024 23:13:42 +0700 Subject: [PATCH] fix: enable text selection codeblock --- web/screens/Chat/SimpleTextMessage/index.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/web/screens/Chat/SimpleTextMessage/index.tsx b/web/screens/Chat/SimpleTextMessage/index.tsx index 7ebc0ebb1..8754664aa 100644 --- a/web/screens/Chat/SimpleTextMessage/index.tsx +++ b/web/screens/Chat/SimpleTextMessage/index.tsx @@ -85,11 +85,10 @@ const SimpleTextMessage: React.FC = (props) => { const codeBlockCopyEvent = useRef((e: Event) => { const target: HTMLElement = e.target as HTMLElement if (typeof target.className !== 'string') return null - const isCopyActionClassName = target?.className.includes('copy-action') - const isCodeBlockParent = - target.parentElement?.parentElement?.className.includes('code-block') - if (isCopyActionClassName || isCodeBlockParent) { + const isCopyActionClassName = target?.className.includes('copy-action') + + if (isCopyActionClassName) { const content = target?.parentNode?.querySelector('code')?.innerText ?? '' clipboard.copy(content) }