Skip to content

fix(spaces): prevent duplicate "Leave without saving?" modal on solution view cancel#260958

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-duplicate-modal-in-edit-space
Draft

fix(spaces): prevent duplicate "Leave without saving?" modal on solution view cancel#260958
Copilot wants to merge 2 commits intomainfrom
copilot/fix-duplicate-modal-in-edit-space

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

Changing the solution view in the edit Space page and then clicking Cancel caused the "Leave without saving?" modal to appear twice — once on Cancel, and again after clicking Leave.

Root cause

onSolutionViewChange calls onChangeFeatures, which sets both isDirty=true and showUserImpactWarning=true. When the user clicks Cancel, onClickCancel calls setShowUserImpactWarning(false) — a real state transition — triggering a React re-render while history.push('/') is already in flight. During that re-render, useUnsavedChangesPrompt re-runs its effect (its props object is a new reference every render), which tears down the old history block and registers a new one. The user's "Leave" click unblocks only the old block; navigateToUrl() then hits the new block and shows the modal again.

This only manifests for solution view changes because it's the only path that sets showUserImpactWarning=true, making setShowUserImpactWarning(false) in onClickCancel a meaningful state change that causes a re-render.

Fix

Add setIsDirty(false) to onClickCancel. Since React batches state updates within event handlers, history.push('/') still fires synchronously against the existing block (modal appears as expected). But on the subsequent re-render, useUnsavedChangesPrompt sees hasUnsavedChanges=false and exits early — no new block is registered, so navigateToUrl() navigates cleanly.

 const onClickCancel = useCallback(() => {
   setShowAlteringActiveSpaceDialog(false);
   setShowUserImpactWarning(false);
+  setIsDirty(false);
   backToSpacesList();
 }, [backToSpacesList]);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ci-stats.kibana.dev
    • Triggering command: /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node scripts/yarn_install_scripts.js run ldd 0.8.2 nibrowser-gtk/sys/lib/libjxl.so.0.8 plugins/private/canvas/public/components/with_debounce_arg/index.ts e_modules/npm/bin/node-gyp-bin/ldd plugins/private//lib64/ld-linux-x86-64.so.2 plugins/private/--verify plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/lib/libwpe-1.0.so.1.9.3 ldd b/li�� plugins/private/install plugins/private/canvas/public/components/palette_picker/stops_palette_picker/stop_color_picker.t/home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libsoup-3.0.so.0.7.4 n/node-gyp-bin/ldd ]*/[^/]*/share/mldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 dd .2 (dns block)
    • Triggering command: /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node scripts/kbn bootstrap ases/public/comp/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/monitoring/server/lib/details/get_series.ts ases�� ases/public/components/observables/observable_actions_popover_button.test.tsx ases/public/components/observables/fields_config.ts plugins/shared/ml/public/applica/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/shared/s^(prefix|globalconfig) *= plugins/shared/mcurl plugins/shared/m-V plugins/shared/ml/public/applicauseUnsavedChangesPrompt plugins/shared/ml/public/applica/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/monitoring/server/lib/elasticsearch/indices/get_indices.ts plug�� plugins/shared/ml/public/applica/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/head plugins/shared/cases/public/comp/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/-n plugins/shared/cases/public/comp/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/private/1 plugins/shared/cawk plugins/shared/cBEGIN { if (ARGV[1] == "" || ARGV[2] == "") exit(1) split(ARGV[1], a, /\./); split(ARGV[2], b, /\./); for (i=1; i<=3; i++) { if (a[i] && a[i] !~ /^[0-9]+$/) exit(2); if (b[i] && b[i] !~ /^[0-9]+$/) { exit(0); } if (a[i] < plugins/shared/cases/public/comp--log-level (dns block)
    • Triggering command: /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node node scripts/jest x-pack/platform/plugins/shared/spaces/public/management/edit_space/edit_space_general_tab.test.tsx --no-coverage s/li�� x-pack/platform/plugins/shared/s^(prefix|globalconfig) *= x-pack/platform/plugins/shared/streams_app/publif() { test "$1" = get && echo "****** v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd x-pack/platform/git x-pack/platform/remote s/npm/bin/node-gget-url ldd nibr�� x-pack/platform/plugins/private/1 r ndor/bin/ldd x-pack/platform/git x-pack/platform/config s/npm/bin/node-guser.email /lib64/ld-linux-x86-64.so.2 (dns block)
  • clients3.google.com
    • Triggering command: /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon run :build-webpack ldd b/li�� plugins/private/NVM_DIR=/home/REDACTED/.nvm plugins/private/-v dd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li�� dd /lib/ld-linux.so.2 b/li�� plugins/private/canvas/public/co--fail plugins/private/canvas/public/co--compressed m/versions/node/v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 x-pack/platform/plugins/shared/s-o ldd (dns block)
  • detectportal.firefox.com
    • Triggering command: /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon run :build-webpack ldd b/li�� plugins/private/NVM_DIR=/home/REDACTED/.nvm plugins/private/-v dd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li�� dd /lib/ld-linux.so.2 b/li�� plugins/private/canvas/public/co--fail plugins/private/canvas/public/co--compressed m/versions/node/v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 x-pack/platform/plugins/shared/s-o ldd (dns block)
  • google.com
    • Triggering command: /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon /home/REDACTED/work/kibana/kibana/node_modules/@moonrepo/core-linux-x64-gnu/moon run :build-webpack ldd b/li�� plugins/private/NVM_DIR=/home/REDACTED/.nvm plugins/private/-v dd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li�� dd /lib/ld-linux.so.2 b/li�� plugins/private/canvas/public/co--fail plugins/private/canvas/public/co--compressed m/versions/node/v22.22.0/lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/private/ldd plugins/private//home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/lib/libjxl.so.0.8 x-pack/platform/plugins/shared/s-o ldd (dns block)
  • googlechromelabs.github.io
    • Triggering command: /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node /home/REDACTED/.nvm/versions/node/v22.22.0/bin/node install.js plugins/shared/alerting/server/application/backfill/methods/schedule/index.ts ldd b/li�� plugins/shared/a--show-toplevel system# !d; /lib/node_modules/npm/bin/node-gyp-bin/ldd plugins/shared/aldd plugins/shared/a/home/REDACTED/.cache/ms-playwright/webkit-2248/minibrowser-wpe/sys/li�� (dns block)
  • iojs.org
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - treams_app/publipush treams_app/publi-v treams_app/publiorigin trea�� treams_app/publi/home/REDACTED/work/kibana/kibana/x-pack/platform/plugins/shared/entity_manager/setr canvas/public/components/arg_form/arg_simple_form.tsx canvas/public/components/color_dot/index.ts canvas/public/cobash canvas/public/co--norc canvas/public/co--noprofile canvas/public/components/with_debounce_arg/index.ts (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@elasticmachine
Copy link
Copy Markdown
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!
  • Click to trigger kibana-entity-store-performance-from-pr for this PR!
  • Click to trigger kibana-storybooks-from-pr for this PR!

Copilot AI changed the title [WIP] Fix duplicate modal in edit Space on Solution view change fix(spaces): prevent duplicate "Leave without saving?" modal on solution view cancel Apr 2, 2026
Copilot AI requested a review from legrego April 2, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicte modal in edit Space on Solution view change

3 participants