mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 12:17:49 +08:00
FIX: Don't try to focus on a missing element (#11766)
Replacing 3 imports and flawed fragile logic with a single html attribute 💆
This commit is contained in:
@ -1,16 +1,12 @@
|
|||||||
import discourseComputed, {
|
|
||||||
observes,
|
|
||||||
on,
|
|
||||||
} from "discourse-common/utils/decorators";
|
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import bootbox from "bootbox";
|
import bootbox from "bootbox";
|
||||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
||||||
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { or } from "@ember/object/computed";
|
import { or } from "@ember/object/computed";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import { schedule } from "@ember/runloop";
|
|
||||||
|
|
||||||
export default Component.extend(bufferedProperty("host"), {
|
export default Component.extend(bufferedProperty("host"), {
|
||||||
editToggled: false,
|
editToggled: false,
|
||||||
@ -19,14 +15,6 @@ export default Component.extend(bufferedProperty("host"), {
|
|||||||
|
|
||||||
editing: or("host.isNew", "editToggled"),
|
editing: or("host.isNew", "editToggled"),
|
||||||
|
|
||||||
@on("didInsertElement")
|
|
||||||
@observes("editing")
|
|
||||||
_focusOnInput() {
|
|
||||||
schedule("afterRender", () => {
|
|
||||||
this.element.querySelector(".host-name").focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
@discourseComputed("buffered.host", "host.isSaving")
|
@discourseComputed("buffered.host", "host.isSaving")
|
||||||
cantSave(host, isSaving) {
|
cantSave(host, isSaving) {
|
||||||
return isSaving || isEmpty(host);
|
return isSaving || isEmpty(host);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{{#if editing}}
|
{{#if editing}}
|
||||||
<td class="editing-input">
|
<td class="editing-input">
|
||||||
<div class="label">{{i18n "admin.embedding.host"}}</div>
|
<div class="label">{{i18n "admin.embedding.host"}}</div>
|
||||||
{{input value=buffered.host placeholder="example.com" enter=(action "save") class="host-name"}}
|
{{input value=buffered.host placeholder="example.com" enter=(action "save") class="host-name" autofocus=true}}
|
||||||
</td>
|
</td>
|
||||||
<td class="editing-input">
|
<td class="editing-input">
|
||||||
<div class="label">{{i18n "admin.embedding.class_name"}}</div>
|
<div class="label">{{i18n "admin.embedding.class_name"}}</div>
|
||||||
|
Reference in New Issue
Block a user