Skip to content

Commit 6f36c5a

Browse files
authored
Bugfix 'new' confirmation on dirty scratch (#1708)
1 parent c5f5f6a commit 6f36c5a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

frontend/src/components/Scratch/Scratch.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,16 @@ export default function Scratch({
168168
const compilerOptsScrollPosition = useRef(0);
169169

170170
const [isModified, setIsModified] = useState(false);
171+
const [isDirty, setIsDirty] = useState(false);
171172
const setScratch = (scratch: Partial<api.Scratch>) => {
172173
onChange(scratch);
173174
setIsModified(true);
175+
setIsDirty(true);
174176
};
175177
const [perSaveObj, setPerSaveObj] = useState({});
176178
const saveCallback = () => {
177179
setPerSaveObj({});
180+
setIsDirty(false);
178181
};
179182

180183
const shouldCompare = !isModified;
@@ -466,7 +469,7 @@ export default function Scratch({
466469
isCompiling={isCompiling}
467470
scratch={scratch}
468471
setScratch={setScratch}
469-
isModified={isModified}
472+
isDirty={isDirty}
470473
saveCallback={saveCallback}
471474
setDecompilationTabEnabled={setDecompilationTabEnabled}
472475
/>

frontend/src/components/Scratch/ScratchToolbar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function ScratchName({
151151

152152
function Actions({
153153
isCompiling,
154-
isModified,
154+
isDirty,
155155
compile,
156156
scratch,
157157
setScratch,
@@ -195,7 +195,7 @@ function Actions({
195195
<button
196196
onClick={() => {
197197
if (
198-
!isModified ||
198+
!isDirty ||
199199
confirm(
200200
"This scratch has pending changes, are you sure you want to navigate away?",
201201
)
@@ -322,7 +322,7 @@ function useActionsLocation(): [ActionsLocation, FC<Props>] {
322322

323323
export type Props = {
324324
isCompiling: boolean;
325-
isModified: boolean;
325+
isDirty: boolean;
326326
compile: () => Promise<void>;
327327
scratch: Readonly<api.Scratch>;
328328
setScratch: (scratch: Partial<api.Scratch>) => void;

0 commit comments

Comments
 (0)