From 752c43376e8fccffea7dbf3fdbbcc4c964c49798 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Wed, 10 Mar 2021 19:23:27 -0500 Subject: [PATCH] Run oninput and input listeners on timeout This is necessary for the setTimeout callback to be run after the new value has been applied; otherwise, mobile iOS doesn't respect the timeout. Fixes https://github.com/flarum/core/issues/2681 --- .../markdown/js/src/forum/util/MarkdownAreaEditorDriver.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/markdown/js/src/forum/util/MarkdownAreaEditorDriver.js b/extensions/markdown/js/src/forum/util/MarkdownAreaEditorDriver.js index 5dff8ca66..69a9e51f7 100644 --- a/extensions/markdown/js/src/forum/util/MarkdownAreaEditorDriver.js +++ b/extensions/markdown/js/src/forum/util/MarkdownAreaEditorDriver.js @@ -14,10 +14,12 @@ export class MarkdownEditorFlarumExtension { postfix, evt ) { - // setTimeout without a time executes after the call stack has cleared, + // setTimeout executes after the call stack has cleared, // so any DOM changes originating from mdarea (e.g. executing an undo) // will be finished by then. At that time, `e.target.value` will represent // the updated value of the textarea in response to the keypress. + // Unfortunately, this doesn't work without a value for mobile safari, + // so we need to set 10 seconds as an arbitrary timeout. setTimeout(() => { this.oninput(evt.target.value); @@ -26,7 +28,7 @@ export class MarkdownEditorFlarumExtension { } this.callInputListeners(evt); - }); + }, 25); } }