mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	settings: Prevent redundant requests by modifying event handler.
Previously, all buttons within .subsection-changes-save were targeted, potentially leading to multiple requests while a request was in progress. This change ensures that the triggering element is properly handled by preventing the default form submission action.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							86eb69a68b
						
					
				
				
					commit
					e3a1ad7a3c
				
			@@ -1255,7 +1255,7 @@ export function register_save_discard_widget_handlers(
 | 
			
		||||
 | 
			
		||||
    $container.on(
 | 
			
		||||
        "click",
 | 
			
		||||
        ".subsection-header .subsection-changes-save button",
 | 
			
		||||
        ".subsection-header .subsection-changes-save .save-button[data-status='unsaved']",
 | 
			
		||||
        function (this: HTMLElement, e: JQuery.ClickEvent) {
 | 
			
		||||
            e.preventDefault();
 | 
			
		||||
            e.stopPropagation();
 | 
			
		||||
@@ -1275,6 +1275,15 @@ export function register_save_discard_widget_handlers(
 | 
			
		||||
            save_organization_settings(data, $save_button, patch_url, success_continuation);
 | 
			
		||||
        },
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    $container.on(
 | 
			
		||||
        "click",
 | 
			
		||||
        ".subsection-header .subsection-changes-save button",
 | 
			
		||||
        (e: JQuery.ClickEvent) => {
 | 
			
		||||
            // Prevents the default form submission action when clicking a button (e.g., "Saving...").
 | 
			
		||||
            e.preventDefault();
 | 
			
		||||
        },
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Exported for tests
 | 
			
		||||
 
 | 
			
		||||
@@ -816,7 +816,7 @@ export function initialize(): void {
 | 
			
		||||
 | 
			
		||||
    $("#channels_overlay_container").on(
 | 
			
		||||
        "click",
 | 
			
		||||
        ".subsection-header .subsection-changes-save button",
 | 
			
		||||
        ".subsection-header .subsection-changes-save .save-button[data-status='unsaved']",
 | 
			
		||||
        function (this: HTMLElement, e) {
 | 
			
		||||
            e.preventDefault();
 | 
			
		||||
            e.stopPropagation();
 | 
			
		||||
 
 | 
			
		||||
@@ -1058,7 +1058,7 @@ export function show_settings_for(group: UserGroup): void {
 | 
			
		||||
        .find(".realm-group-permissions")
 | 
			
		||||
        .on(
 | 
			
		||||
            "click",
 | 
			
		||||
            ".subsection-header .subsection-changes-save button",
 | 
			
		||||
            ".subsection-header .subsection-changes-save .save-button[data-status='unsaved']",
 | 
			
		||||
            function (this: HTMLElement, e: JQuery.ClickEvent) {
 | 
			
		||||
                e.preventDefault();
 | 
			
		||||
                e.stopPropagation();
 | 
			
		||||
@@ -1073,7 +1073,7 @@ export function show_settings_for(group: UserGroup): void {
 | 
			
		||||
        .find(".channel-group-permissions")
 | 
			
		||||
        .on(
 | 
			
		||||
            "click",
 | 
			
		||||
            ".subsection-header .subsection-changes-save button",
 | 
			
		||||
            ".subsection-header .subsection-changes-save .save-button[data-status='unsaved']",
 | 
			
		||||
            function (this: HTMLElement, e: JQuery.ClickEvent) {
 | 
			
		||||
                e.preventDefault();
 | 
			
		||||
                e.stopPropagation();
 | 
			
		||||
@@ -1095,7 +1095,7 @@ export function show_settings_for(group: UserGroup): void {
 | 
			
		||||
        .find(".user-group-permissions")
 | 
			
		||||
        .on(
 | 
			
		||||
            "click",
 | 
			
		||||
            ".subsection-header .subsection-changes-save button",
 | 
			
		||||
            ".subsection-header .subsection-changes-save .save-button[data-status='unsaved']",
 | 
			
		||||
            function (this: HTMLElement, e: JQuery.ClickEvent) {
 | 
			
		||||
                e.preventDefault();
 | 
			
		||||
                e.stopPropagation();
 | 
			
		||||
@@ -2034,7 +2034,7 @@ export function initialize(): void {
 | 
			
		||||
 | 
			
		||||
    $("#groups_overlay_container").on(
 | 
			
		||||
        "click",
 | 
			
		||||
        ".subsection-header .subsection-changes-save button",
 | 
			
		||||
        ".subsection-header .subsection-changes-save .save-button[data-status='unsaved']",
 | 
			
		||||
        function (this: HTMLElement, e) {
 | 
			
		||||
            e.preventDefault();
 | 
			
		||||
            e.stopPropagation();
 | 
			
		||||
 
 | 
			
		||||
@@ -573,7 +573,7 @@ test("set_up", ({override, override_rewire}) => {
 | 
			
		||||
        override,
 | 
			
		||||
        $(".admin-realm-form").get_on_handler(
 | 
			
		||||
            "click",
 | 
			
		||||
            ".subsection-header .subsection-changes-save button",
 | 
			
		||||
            ".subsection-header .subsection-changes-save .save-button[data-status='unsaved']",
 | 
			
		||||
        ),
 | 
			
		||||
    );
 | 
			
		||||
    test_upload_realm_icon(override, upload_realm_logo_or_icon);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user