From 187c4024a264454b845e38da3723ffb710277eff Mon Sep 17 00:00:00 2001 From: MrTasken <34338909+MrTasken@users.noreply.github.com> Date: Mon, 23 Apr 2018 17:27:12 +0200 Subject: [PATCH] Makes refocusing work This fixes a possible race condition, that the focus refocuses before the browser has even changed focus. --- src/scribe-plugin-toolbar.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/scribe-plugin-toolbar.js b/src/scribe-plugin-toolbar.js index 6353f2d..ff1c3b6 100644 --- a/src/scribe-plugin-toolbar.js +++ b/src/scribe-plugin-toolbar.js @@ -42,7 +42,9 @@ define(function () { * It is important that we focus the instance again before executing * the command, because it might rely on selection data. */ - scribe.el.focus(); + setTimeout(function() { + scribe.el.focus(); + }, 0); command.execute(button.dataset.commandValue); /** * Chrome has a bit of magic to re-focus the `contenteditable` when a