From 6cdaa48cdc283e050c07c900e8c48ff97d6f08ce Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 11 Mar 2021 10:02:41 +1000 Subject: [PATCH] Backport merge pull request #1063 from hgiesel/edithtmlfix Fix bug with initially enabled toolbar in browser --- ts/editor/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ts/editor/index.ts b/ts/editor/index.ts index 2a8a811a9..130e26dbc 100644 --- a/ts/editor/index.ts +++ b/ts/editor/index.ts @@ -5,7 +5,7 @@ import { nodeIsInline, caretToEnd } from "./helpers"; import { bridgeCommand } from "./lib"; import { saveField } from "./changeTimer"; import { filterHTML } from "./htmlFilter"; -import { updateButtonState } from "./toolbar"; +import { updateButtonState, disableButtons } from "./toolbar"; import { onInput, onKey, onKeyUp } from "./inputHandlers"; import { onFocus, onBlur } from "./focusHandlers"; @@ -302,6 +302,11 @@ export function setFields(fields: [string, string][]): void { forEditorField(fields, (field, [name, fieldContent]) => field.initialize(name, color, fieldContent) ); + + if (!getCurrentField()) { + // when initial focus of the window is not on editor (e.g. browser) + disableButtons(); + } } export function setBackgrounds(cols: ("dupe" | "")[]) {