From 9d317128a08a66f18c4d51385b6a9fccc5cd66f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20K=C3=BChn?= Date: Thu, 20 Jan 2022 21:37:31 +0100 Subject: [PATCH] fix: fix removing the caret on blur in some situations when using safari, fix #2405 --- packages/core/src/commands/blur.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/src/commands/blur.ts b/packages/core/src/commands/blur.ts index 4663ffea..ac603e82 100644 --- a/packages/core/src/commands/blur.ts +++ b/packages/core/src/commands/blur.ts @@ -15,6 +15,10 @@ export const blur: RawCommands['blur'] = () => ({ editor, view }) => { requestAnimationFrame(() => { if (!editor.isDestroyed) { (view.dom as HTMLElement).blur() + + // Browsers should remove the caret on blur but safari does not. + // See: https://github.com/ueberdosis/tiptap/issues/2405 + window?.getSelection()?.removeAllRanges() } })