From 21aa015a79f909e5602f779c1ae50cb4d404710c Mon Sep 17 00:00:00 2001 From: Cesaryuan Date: Wed, 14 Jun 2023 14:30:08 +0800 Subject: [PATCH 1/2] 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, From b4cb8c3d75feb7db1e092b533513704690373f97 Mon Sep 17 00:00:00 2001 From: Cesaryuan Date: Wed, 14 Jun 2023 14:40:51 +0800 Subject: [PATCH 2/2] chore: translate comment to english --- app/components/mask.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/components/mask.tsx b/app/components/mask.tsx index af067ed4..d48ed7c2 100644 --- a/app/components/mask.tsx +++ b/app/components/mask.tsx @@ -187,7 +187,8 @@ function ContextPromptItem(props: { onFocus={() => setFocusingInput(true)} onBlur={() => { setFocusingInput(false); - // 如果在用户失去焦点时不清除选区,那么一些依赖类似「划词翻译」的扩展会始终显示浮动条 + // If the selection is not removed when the user loses focus, some + // extensions like "Translate" will always display a floating bar window?.getSelection()?.removeAllRanges(); }} onInput={(e) =>