FIX: move-topics topic search losing focus (#25116)

- [Meta Report](https://meta.discourse.org/t/moving-posts-the-input-focus-shifts-when-searching-for-a-topic-to-move-a-post-to-as-typing/284924/1)

### Correct Focus kept during Search
https://github.com/discourse/discourse/assets/50783505/ae9b4480-208e-470a-98c4-5ba10a053eb7

### Search Log after search
<img width="430" alt="Screenshot 2024-01-03 at 11 08 08 AM" src="https://github.com/discourse/discourse/assets/50783505/155f413a-adc1-4e59-a74b-dcef7af01990">
This commit is contained in:
Isaac Janzen 2024-01-03 14:21:43 -07:00 committed by GitHub
parent 46777b379e
commit c689eeef31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 13 deletions

View File

@ -3,8 +3,10 @@ import { action } from "@ember/object";
import { isEmpty } from "@ember/utils";
import { searchForTerm } from "discourse/lib/search";
import { INPUT_DELAY } from "discourse-common/config/environment";
import discourseDebounce from "discourse-common/lib/debounce";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import discourseComputed, {
debounce,
observes,
} from "discourse-common/utils/decorators";
export default Component.extend({
loading: null,
@ -69,7 +71,7 @@ export default Component.extend({
oldTopicTitle: this.topicTitle,
});
this.searchDebounced(this.topicTitle);
this.search(this.topicTitle);
},
@discourseComputed("label")
@ -86,10 +88,7 @@ export default Component.extend({
this.set("loading", false);
},
searchDebounced(title) {
discourseDebounce(this, this.search, title, INPUT_DELAY);
},
@debounce(INPUT_DELAY)
search(title) {
if (!this.element || this.isDestroying || this.isDestroyed) {
return;

View File

@ -95,7 +95,6 @@
{{/if}}
{{else}}
<div class="radios">
{{#if this.canSplitTopic}}
<label class="radio-label" for="move-to-new-topic">
@ -133,16 +132,17 @@
</div>
{{#if this.existingTopic}}
<p>{{html-safe
<p>
{{html-safe
(i18n
"topic.merge_topic.instructions" count=@model.selectedPostsCount
)
}}</p>
}}
</p>
<form>
<ChooseTopic
@currentTopicId={{@model.topic.id}}
@selectedTopicId={{this.selectedTopicId}}
@autoFocus={{this.existingTopic}}
/>
{{#if this.selectedTopicId}}
@ -161,11 +161,13 @@
{{#if this.canSplitTopic}}
{{#if this.newTopic}}
<p>{{html-safe
<p>
{{html-safe
(i18n
"topic.split_topic.instructions" count=@model.selectedPostsCount
)
}}</p>
}}
</p>
<form class="split-new-topic-form">
<div class="control-group">
<label>{{i18n "topic.split_topic.topic_name"}}</label>