From c689eeef3182404ccf5637df83b96b4afb69394d Mon Sep 17 00:00:00 2001
From: Isaac Janzen <50783505+janzenisaac@users.noreply.github.com>
Date: Wed, 3 Jan 2024 14:21:43 -0700
Subject: [PATCH] FIX: `move-topics` topic search losing focus (#25116)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- [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
---
.../discourse/app/components/choose-topic.js | 13 ++++++-------
.../app/components/modal/move-to-topic.hbs | 14 ++++++++------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/app/assets/javascripts/discourse/app/components/choose-topic.js b/app/assets/javascripts/discourse/app/components/choose-topic.js
index 2b6c87aa74f..eb36332c7c0 100644
--- a/app/assets/javascripts/discourse/app/components/choose-topic.js
+++ b/app/assets/javascripts/discourse/app/components/choose-topic.js
@@ -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;
diff --git a/app/assets/javascripts/discourse/app/components/modal/move-to-topic.hbs b/app/assets/javascripts/discourse/app/components/modal/move-to-topic.hbs
index e9cf2409476..e6afc45051a 100644
--- a/app/assets/javascripts/discourse/app/components/modal/move-to-topic.hbs
+++ b/app/assets/javascripts/discourse/app/components/modal/move-to-topic.hbs
@@ -95,7 +95,6 @@
{{/if}}
{{else}}
-
{{html-safe +
+ {{html-safe (i18n "topic.merge_topic.instructions" count=@model.selectedPostsCount ) - }}
+ }} +