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:
Jarek Radosz
2025-01-21 11:24:33 +01:00
committed by GitHub
parent db998ee1ab
commit 184ec95d01
5 changed files with 33 additions and 48 deletions

View File

@@ -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();
});
}