settings_ui: Use overlays.open_modal in user deactivation settings.

Hiding and instantly showing a modal causes a race condition in
Bootstrap since `hide` and `show` calls are asynchronous.
See https://getbootstrap.com/docs/4.0/components/modal/#methods

Instead, use `overlays.open_modal` which prevents background
mouse events when a modal is present.

This prevents a user from maybe accidentally clicking on another deactivate
button while a modal is present. This also prevents a black screen
caused due to this race condition.

And since a user can't click on the button while the modal is present,
it doesn't make sense to hide it before showing it.
So, remove the `hide` call.

Fixes #17297
This commit is contained in:
Ganesh Pawar
2021-02-13 22:42:43 +05:30
parent d4248cf060
commit d0f8515b50

View File

@@ -538,11 +538,10 @@ function confirm_deactivation(row, user_id, status_field) {
settings_ui.do_settings_change(channel.del, url, {}, status_field, opts);
}
modal_elem.modal("hide");
modal_elem.off("click", ".do_deactivate_button");
set_fields();
modal_elem.on("click", ".do_deactivate_button", handle_confirm);
modal_elem.modal("show");
overlays.open_modal("#deactivation_user_modal");
}
function handle_deactivation(tbody, status_field) {