diff --git a/web/src/dialog_widget.ts b/web/src/dialog_widget.ts index a751c5f381..69b1c94ef9 100644 --- a/web/src/dialog_widget.ts +++ b/web/src/dialog_widget.ts @@ -92,7 +92,7 @@ export function hide_dialog_spinner(): void { const $spinner = $(`${dialog_widget_selector} .modal__spinner`); $(`${dialog_widget_selector} .modal__button`).prop("disabled", false); - loading.hide_spinner($(".dialog_submit_button"), $spinner); + loading.hide_button_spinner($(".dialog_submit_button"), $spinner); } export function show_dialog_spinner(): void { @@ -102,7 +102,7 @@ export function show_dialog_spinner(): void { const $spinner = $(`${dialog_widget_selector} .modal__spinner`); - loading.show_spinner($(".dialog_submit_button"), $spinner); + loading.show_button_spinner($(".dialog_submit_button"), $spinner); } // Supports a callback to be called once the modal finishes closing. diff --git a/web/src/loading.ts b/web/src/loading.ts index d40d48e230..6b03821c88 100644 --- a/web/src/loading.ts +++ b/web/src/loading.ts @@ -81,7 +81,7 @@ export function destroy_indicator($container: JQuery): void { $container.css({width: 0, height: 0}); } -export function show_spinner($button_element: JQuery, $spinner: JQuery): void { +export function show_button_spinner($button_element: JQuery, $spinner: JQuery): void { const span_width = $button_element.find(".submit-button-text").width(); const span_height = $button_element.find(".submit-button-text").height(); @@ -96,7 +96,7 @@ export function show_spinner($button_element: JQuery, $spinner: JQuery): void { }); } -export function hide_spinner($button_element: JQuery, $spinner: JQuery): void { +export function hide_button_spinner($button_element: JQuery, $spinner: JQuery): void { // Show the span $button_element.find(".submit-button-text").show(); diff --git a/web/src/message_edit.ts b/web/src/message_edit.ts index 6fcfef4cae..2b4307df2f 100644 --- a/web/src/message_edit.ts +++ b/web/src/message_edit.ts @@ -345,7 +345,7 @@ export function hide_message_edit_spinner($row: JQuery): void { } export function show_message_edit_spinner($row: JQuery): void { - loading.show_spinner($row, $row.find(".modal__spinner")); + loading.show_button_spinner($row, $row.find(".modal__spinner")); $row.find(".message_edit_save span").hide(); $row.find(".message_edit_save").addClass("message-edit-button-disabled"); $row.find(".message_edit_cancel").addClass("message-edit-button-disabled"); diff --git a/web/src/user_profile.ts b/web/src/user_profile.ts index a4d520194e..c2b61fe927 100644 --- a/web/src/user_profile.ts +++ b/web/src/user_profile.ts @@ -89,13 +89,13 @@ const EMBEDDED_BOT_TYPE = "4"; export function show_button_spinner($button: JQuery): void { const $spinner = $button.find(".modal__spinner"); $button.prop("disabled", true); - loading.show_spinner($button, $spinner); + loading.show_button_spinner($button, $spinner); } export function hide_button_spinner($button: JQuery): void { const $spinner = $button.find(".modal__spinner"); $button.prop("disabled", false); - loading.hide_spinner($button, $spinner); + loading.hide_button_spinner($button, $spinner); } function compare_by_name( diff --git a/web/tests/compose.test.cjs b/web/tests/compose.test.cjs index cc33f57730..30d2229091 100644 --- a/web/tests/compose.test.cjs +++ b/web/tests/compose.test.cjs @@ -401,8 +401,11 @@ test_ui("enter_with_preview_open", ({override, override_rewire}) => { override_rewire(compose_banner, "clear_message_sent_banners", noop); override(document, "to_$", () => $("document-stub")); let show_button_spinner_called = false; - override(loading, "show_button_spinner", ($spinner) => { - assert.equal($spinner.selector, ".compose-submit-button .loader"); + override(loading, "show_button_spinner", ($button_element, $spinner) => { + // Check that the correct button and spinner elements are passed + assert.equal($button_element.selector, ".compose-submit-button"); + assert.equal($spinner.selector, ".compose-submit-button .modal__spinner"); + show_button_spinner_called = true; }); @@ -449,8 +452,11 @@ test_ui("finish", ({override, override_rewire}) => { override_rewire(compose_banner, "clear_message_sent_banners", noop); override(document, "to_$", () => $("document-stub")); let show_button_spinner_called = false; - override(loading, "show_button_spinner", ($spinner) => { - assert.equal($spinner.selector, ".compose-submit-button .loader"); + override(loading, "show_button_spinner", ($button_element, $spinner) => { + // Check that the correct button and spinner elements are passed + assert.equal($button_element.selector, ".compose-submit-button"); + assert.equal($spinner.selector, ".compose-submit-button .modal__spinner"); + show_button_spinner_called = true; });