FIX: ignore enter key press on "move to existing post" search field (#12210)

UX: do not set focus on auto-selected radio option
This commit is contained in:
Arpit Jalan 2021-02-25 23:41:12 +05:30 committed by GitHub
parent 0e65c2b3c8
commit ae70a23525
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ import discourseComputed, { observes } from "discourse-common/utils/decorators";
import Component from "@ember/component"; import Component from "@ember/component";
import discourseDebounce from "discourse-common/lib/debounce"; import discourseDebounce from "discourse-common/lib/debounce";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { next } from "@ember/runloop"; import { next, schedule } from "@ember/runloop";
import { searchForTerm } from "discourse/lib/search"; import { searchForTerm } from "discourse/lib/search";
export default Component.extend({ export default Component.extend({
@ -39,6 +39,22 @@ export default Component.extend({
} }
}, },
didInsertElement() {
this._super(...arguments);
schedule("afterRender", () => {
$("#choose-topic-title").keydown((e) => {
if (e.keyCode === 13) {
return false;
}
});
});
},
willDestroyElement() {
this._super(...arguments);
$("#choose-topic-title").off("keydown");
},
@observes("topicTitle") @observes("topicTitle")
topicTitleChanged() { topicTitleChanged() {
this.setProperties({ this.setProperties({
@ -113,7 +129,6 @@ export default Component.extend({
this.set("selectedTopicId", topic.id); this.set("selectedTopicId", topic.id);
next(() => { next(() => {
document.getElementById(`choose-topic-${topic.id}`).checked = true; document.getElementById(`choose-topic-${topic.id}`).checked = true;
document.getElementById(`choose-topic-${topic.id}`).focus();
}); });
if (this.topicChangedCallback) { if (this.topicChangedCallback) {
this.topicChangedCallback(topic); this.topicChangedCallback(topic);