mirror of
https://github.com/flarum/core.git
synced 2025-07-23 17:51:24 +02:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user