You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ms...@apache.org on 2026/02/05 21:27:31 UTC
(superset) branch msyavuz/chore/unsaved-changes-new-charts created (now b8229913a05)
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a change to branch msyavuz/chore/unsaved-changes-new-charts
in repository https://gitbox.apache.org/repos/asf/superset.git
at b8229913a05 fix(explore): Don't show unsaved changes modal on new charts
This branch includes the following new commits:
new b8229913a05 fix(explore): Don't show unsaved changes modal on new charts
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(superset) 01/01: fix(explore): Don't show unsaved changes modal on new charts
Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
msyavuz pushed a commit to branch msyavuz/chore/unsaved-changes-new-charts
in repository https://gitbox.apache.org/repos/asf/superset.git
commit b8229913a055f00c2c716da3df2ec04c15ca01dd
Author: Mehmet Salih Yavuz <sa...@proton.me>
AuthorDate: Fri Feb 6 00:27:00 2026 +0300
fix(explore): Don't show unsaved changes modal on new charts
---
.../components/ExploreChartHeader/index.jsx | 23 ++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx
index dccc438a187..21ee14b4b15 100644
--- a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx
+++ b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx
@@ -192,13 +192,23 @@ export const ExploreChartHeader = ({
const metadataBar = useExploreMetadataBar(metadata, slice);
const oldSliceName = slice?.slice_name;
+ // Capture initial form data for new charts
+ const [initialFormDataForNewChart] = useState(() =>
+ !slice ? { ...formData, chartTitle: oldSliceName } : null,
+ );
+
const originalFormData = useMemo(() => {
+ // For new charts (no slice), use the captured initial formData
+ if (!slice && initialFormDataForNewChart) {
+ return initialFormDataForNewChart;
+ }
+ // For existing charts, use the saved sliceFormData if available
if (!sliceFormData) return {};
return {
...sliceFormData,
chartTitle: oldSliceName,
};
- }, [sliceFormData, oldSliceName]);
+ }, [sliceFormData, oldSliceName, slice, initialFormDataForNewChart]);
const currentFormData = useMemo(
() => ({ ...formData, chartTitle: sliceName }),
@@ -210,6 +220,15 @@ export const ExploreChartHeader = ({
[originalFormData, currentFormData],
);
+ useEffect(() => {
+ console.log('slice:', slice);
+ console.log('sliceFormData:', sliceFormData);
+ console.log('formDiffs:', formDiffs);
+ console.log('hasUnsavedChanges:', Object.keys(formDiffs).length > 0);
+ }, [slice, sliceFormData, formDiffs]);
+
+ const hasUnsavedChanges = Object.keys(formDiffs).length > 0;
+
const {
showModal: showUnsavedChangesModal,
setShowModal: setShowUnsavedChangesModal,
@@ -217,7 +236,7 @@ export const ExploreChartHeader = ({
handleSaveAndCloseModal,
triggerManualSave,
} = useUnsavedChangesPrompt({
- hasUnsavedChanges: Object.keys(formDiffs).length > 0,
+ hasUnsavedChanges,
onSave: () => dispatch(setSaveChartModalVisibility(true)),
isSaveModalVisible,
manualSaveOnUnsavedChanges: true,