mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
message_move: Initialize ResizeObserver for Rename topic modal.
This commit fixes a bug where the Rename topic modal did not resize
when the "topic already exists" warning was shown or hidden. This
caused the topic edit typeahead for topics in a channel
with similar prefixes to be misaligned.
(cherry picked from commit 725fd707fe)
This commit is contained in:
committed by
Tim Abbott
parent
5918266544
commit
1c6fba6c8f
@@ -771,6 +771,20 @@ export async function build_move_topic_to_stream_popover(
|
||||
}
|
||||
}
|
||||
|
||||
function setup_resize_observer($topic_input: JQuery<HTMLInputElement>): void {
|
||||
// Update position of topic typeahead because showing/hiding the
|
||||
// "topic already exists" warning changes the size of the modal.
|
||||
const update_topic_typeahead_position = new ResizeObserver((_entries) => {
|
||||
requestAnimationFrame(() => {
|
||||
$topic_input.trigger(new $.Event("typeahead.refreshPosition"));
|
||||
});
|
||||
});
|
||||
const move_topic_form = document.querySelector("#move_topic_form");
|
||||
if (move_topic_form) {
|
||||
update_topic_typeahead_position.observe(move_topic_form);
|
||||
}
|
||||
}
|
||||
|
||||
function move_topic_post_render(): void {
|
||||
$("#move_topic_modal .dialog_submit_button").prop("disabled", true);
|
||||
$("#move_topic_modal .move_topic_warning_container").hide();
|
||||
@@ -812,6 +826,8 @@ export async function build_move_topic_to_stream_popover(
|
||||
});
|
||||
}
|
||||
|
||||
setup_resize_observer($topic_input);
|
||||
|
||||
if (only_topic_edit) {
|
||||
// Set select_stream_id to current_stream_id since we user is not allowed
|
||||
// to edit stream in topic-edit only UI.
|
||||
@@ -856,18 +872,6 @@ export async function build_move_topic_to_stream_popover(
|
||||
update_topic_input_placeholder_visibility(topic_input_value);
|
||||
});
|
||||
|
||||
// Update position of topic typeahead because showing/hiding the
|
||||
// "topic already exists" warning changes the size of the modal.
|
||||
const update_topic_typeahead_position = new ResizeObserver((_entries) => {
|
||||
requestAnimationFrame(() => {
|
||||
$topic_input.trigger(new $.Event("typeahead.refreshPosition"));
|
||||
});
|
||||
});
|
||||
const move_topic_form = document.querySelector("#move_topic_form");
|
||||
if (move_topic_form) {
|
||||
update_topic_typeahead_position.observe(move_topic_form);
|
||||
}
|
||||
|
||||
if (!args.from_message_actions_popover) {
|
||||
update_move_messages_count_text("change_all");
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user