mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Don't nest deferring calls (#30449)
Each case simplified:
`next(() => later(() => ...))` -> "wait 0 ms then wait X ms"
`next(() => debounce(() => ...))` -> "wait 0 ms then wait X ms
(debounced)"
`next(() => scheduleAfter("render", ...))` -> "in the next (empty) run
loop, do the thing (after a no-op render step)"
This commit is contained in:
@@ -49,37 +49,33 @@ export default class TextareaInteractor extends EmberObject {
|
||||
@bind
|
||||
blur() {
|
||||
next(() => {
|
||||
schedule("afterRender", () => {
|
||||
this.textarea.blur();
|
||||
});
|
||||
this.textarea.blur();
|
||||
});
|
||||
}
|
||||
|
||||
@bind
|
||||
focus(opts = { ensureAtEnd: false, refreshHeight: true, addText: null }) {
|
||||
next(() => {
|
||||
schedule("afterRender", () => {
|
||||
if (opts.refreshHeight) {
|
||||
this.refreshHeight();
|
||||
}
|
||||
if (opts.refreshHeight) {
|
||||
this.refreshHeight();
|
||||
}
|
||||
|
||||
if (opts.ensureAtEnd) {
|
||||
this.ensureCaretAtEnd();
|
||||
}
|
||||
if (opts.ensureAtEnd) {
|
||||
this.ensureCaretAtEnd();
|
||||
}
|
||||
|
||||
if (this.capabilities.isIpadOS || this.site.mobileView) {
|
||||
return;
|
||||
}
|
||||
if (this.capabilities.isIpadOS || this.site.mobileView) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (opts.addText) {
|
||||
this.textManipulation.addText(
|
||||
this.textManipulation.getSelected(),
|
||||
opts.addText
|
||||
);
|
||||
}
|
||||
if (opts.addText) {
|
||||
this.textManipulation.addText(
|
||||
this.textManipulation.getSelected(),
|
||||
opts.addText
|
||||
);
|
||||
}
|
||||
|
||||
this.textManipulation.blurAndFocus();
|
||||
});
|
||||
this.textManipulation.blurAndFocus();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user