From 809af3b6c6dd2b82cfd4da032181c1f4e93d01cd Mon Sep 17 00:00:00 2001 From: Julian Hundeloh Date: Wed, 15 Dec 2021 09:04:41 +0100 Subject: [PATCH] fix: show FloatingMenu by default only if focused (#2275) --- .../extension-floating-menu/src/floating-menu-plugin.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/extension-floating-menu/src/floating-menu-plugin.ts b/packages/extension-floating-menu/src/floating-menu-plugin.ts index e014455fa..fce0ff529 100644 --- a/packages/extension-floating-menu/src/floating-menu-plugin.ts +++ b/packages/extension-floating-menu/src/floating-menu-plugin.ts @@ -33,7 +33,7 @@ export class FloatingMenuView { public tippyOptions?: Partial - public shouldShow: Exclude = ({ state }) => { + public shouldShow: Exclude = ({ state, view }) => { const { selection } = state const { $anchor, empty } = selection const isRootDepth = $anchor.depth === 1 @@ -41,6 +41,10 @@ export class FloatingMenuView { && !$anchor.parent.type.spec.code && !$anchor.parent.textContent + if (!view.hasFocus()) { + return false + } + if (!empty || !isRootDepth || !isEmptyTextBlock) { return false }