From 21aa015a79f909e5602f779c1ae50cb4d404710c Mon Sep 17 00:00:00 2001 From: Cesaryuan Date: Wed, 14 Jun 2023 14:30:08 +0800 Subject: [PATCH] fix: remove slection range when user blured --- app/components/mask.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/components/mask.tsx b/app/components/mask.tsx index de724e26..af067ed4 100644 --- a/app/components/mask.tsx +++ b/app/components/mask.tsx @@ -185,7 +185,11 @@ function ContextPromptItem(props: { className={chatStyle["context-content"]} rows={focusingInput ? 5 : 1} onFocus={() => setFocusingInput(true)} - onBlur={() => setFocusingInput(false)} + onBlur={() => { + setFocusingInput(false); + // 如果在用户失去焦点时不清除选区,那么一些依赖类似「划词翻译」的扩展会始终显示浮动条 + window?.getSelection()?.removeAllRanges(); + }} onInput={(e) => props.update({ ...props.prompt,