integration-url-modal: Focus on the topic input when it is displayed.

When the override-topic checkbox becomes checked, and the topic-input
gets its "hide" class removed, place the cursor inside the textbox.

Close the stream dropdown before processing the selected option, to
prevent it overriding the focus.
This commit is contained in:
Niloth P
2025-03-08 00:43:07 +05:30
committed by Tim Abbott
parent 1680846f8b
commit 625b41d987

View File

@@ -151,6 +151,9 @@ export function show_generate_integration_url_modal(api_key: string): void {
$override_topic.on("change", function () {
const checked = this.checked;
$topic_input.parent().toggleClass("hide", !checked);
if (!$topic_input.parent().hasClass("hide")) {
$topic_input.trigger("focus");
}
});
$show_integration_events.on("change", () => {
@@ -352,6 +355,7 @@ export function show_generate_integration_url_modal(api_key: string): void {
): void {
stream_input_dropdown_widget.render();
$(".integration-url-stream-wrapper").trigger("input");
dropdown.hide();
const user_selected_option = stream_input_dropdown_widget.value();
if (user_selected_option === direct_messages_option.unique_id) {
$override_topic.prop("checked", false).prop("disabled", true);
@@ -362,8 +366,6 @@ export function show_generate_integration_url_modal(api_key: string): void {
$override_topic.closest(".input-group").removeClass("control-label-disabled");
}
$override_topic.trigger("change");
dropdown.hide();
event.preventDefault();
event.stopPropagation();
}