mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
stream_create: Avoid re-initialization of event handlers.
Previously, Everytime the user triggers the Stream create UI by pressing the `Create stream` button, the `create_handlers_for_users` function would reinitialize which created duplicate event handlers for its elements. This could lead to multiple click events being triggered over the same element. One such example was filed as #19255, where the click event was triggering twice and hence the "Copy from stream" dropdown would remain folded (closed). Fixed this by - Initializing the `create_handlers_for_users` function within the main `set_up_handlers` function, which is triggered only once upon the opening of Stream create UI. Fixes #19255.
This commit is contained in:
committed by
Tim Abbott
parent
a0e3de302f
commit
d8e2fa5f9c
@@ -314,8 +314,6 @@ export function show_new_stream_modal() {
|
||||
html_selector: (user) => $(`#${CSS.escape("user_checkbox_" + user.user_id)}`),
|
||||
});
|
||||
|
||||
create_handlers_for_users(add_people_container);
|
||||
|
||||
// Make the options default to the same each time:
|
||||
// public, "announce stream" on.
|
||||
$("#make-invite-only input:radio[value=public]").prop("checked", true);
|
||||
@@ -394,7 +392,7 @@ export function create_handlers_for_users(container) {
|
||||
$("#copy-from-stream-expand-collapse .toggle").toggleClass("fa-caret-right fa-caret-down");
|
||||
});
|
||||
|
||||
$("#stream-checkboxes label.checkbox").on("change", (e) => {
|
||||
container.on("change", "#stream-checkboxes label.checkbox", (e) => {
|
||||
e.preventDefault();
|
||||
const elem = $(e.target).closest("[data-stream-id]");
|
||||
const stream_id = Number.parseInt(elem.attr("data-stream-id"), 10);
|
||||
@@ -405,6 +403,11 @@ export function create_handlers_for_users(container) {
|
||||
}
|
||||
|
||||
export function set_up_handlers() {
|
||||
// Sets up all the event handlers concerning the `People to add`
|
||||
// section in Create stream UI.
|
||||
const people_to_add_holder = $("#people_to_add").expectOne();
|
||||
create_handlers_for_users(people_to_add_holder);
|
||||
|
||||
const container = $("#stream-creation").expectOne();
|
||||
|
||||
container.on("change", "#make-invite-only input", update_announce_stream_state);
|
||||
|
||||
Reference in New Issue
Block a user