Skip to content

A platform for community discussion. Free, open, simple.

DEV: Fix `ember/no-incorrect-calls-with-inline-anonymous-functions` (#24010)

Jarek Radoszb45720b158e1
diff --git a/app/assets/javascripts/discourse/app/components/user-status-picker.js b/app/assets/javascripts/discourse/app/components/user-status-picker.js
index b5fab3b4fdf..522b6791886 100644
--- a/app/assets/javascripts/discourse/app/components/user-status-picker.js
+++ b/app/assets/javascripts/discourse/app/components/user-status-picker.js
@@ -25,6 +25,10 @@ export default class UserStatusPicker extends Component {
return emojiUnescape(emoji);
}
+ focusEmojiButton() {
+ document.querySelector(".btn-emoji")?.focus();
+ }
+
@action
blur() {
this.set("isFocused", false);
@@ -35,9 +39,7 @@ export default class UserStatusPicker extends Component {
this.set("status.emoji", emoji);
this.set("emojiPickerIsActive", false);
- scheduleOnce("afterRender", () => {
- document.querySelector(".btn-emoji")?.focus();
- });
+ scheduleOnce("afterRender", this, this.focusEmojiButton);
}
@action
diff --git a/app/assets/javascripts/discourse/app/services/composer.js b/app/assets/javascripts/discourse/app/services/composer.js
index 9e930b15927..8c1afa3d895 100644
--- a/app/assets/javascripts/discourse/app/services/composer.js
+++ b/app/assets/javascripts/discourse/app/services/composer.js
@@ -492,7 +492,13 @@ export default class ComposerService extends Service {
@action
async focusComposer(opts = {}) {
await this._openComposerForFocus(opts);
- this._focusAndInsertText(opts.insertText);
+
+ scheduleOnce(
+ "afterRender",
+ this,
+ this._focusAndInsertText,
+ opts.insertText
+ );
}
async _openComposerForFocus(opts) {
@@ -525,13 +531,11 @@ export default class ComposerService extends Service {
}
_focusAndInsertText(insertText) {
- scheduleOnce("afterRender", () => {
- document.querySelector("textarea.d-editor-input")?.focus();
+ document.querySelector("textarea.d-editor-input")?.focus();
- if (insertText) {
- this.model.appendText(insertText, null, { new_line: true });
- }
- });
+ if (insertText) {
+ this.model.appendText(insertText, null, { new_line: true });
+ }
}
@action