Commit 3055037
authored
[2.x] fix: TextEditor.onbuild race against async Mithril redraw (#4657)
`oncreate` called `_load().then(() => setTimeout(this.onbuild, 50))`.
The 50ms timer is a guess at how long it takes Mithril's async
`m.redraw()` to flush — under slow first-load conditions (cold CDN,
heavy DOM, additional `_loaders`) the redraw can land *after* the
timer fires, leaving `this.$('.TextEditor-editorContainer')[0]` as
`undefined` when `onbuild` runs. That `undefined` then propagates
into the editor driver (notably breaking Tiptap-based drivers like
fof/rich-text, where it produces a non-functional toolbar with no
editor underneath).
Use `m.redraw.sync()` in `_load` so the DOM is updated before the
promise resolves, and drop the 50ms timer entirely. The `.then` runs
on a microtask outside any Mithril event handler, so `redraw.sync()`
is safe here.
Closes #46121 parent c57b7a3 commit 3055037
1 file changed
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
| 75 | + | |
78 | 76 | | |
79 | 77 | | |
80 | 78 | | |
| |||
96 | 94 | | |
97 | 95 | | |
98 | 96 | | |
99 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
0 commit comments