File tree Expand file tree Collapse file tree
src/modules/Builder/features/SaveAndPublish Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -315,13 +315,20 @@ export const useSaveAndPublishSetup = (): SaveAndPublishSetup => {
315315 const hasAccessDeniedError =
316316 Array . isArray ( responseError ) &&
317317 responseError . some ( ( error ) => error . type === ErrorResponseType . AccessDenied ) ;
318+ // Use `dirtyFields` (fields the user actually edited) rather than RHF's `isDirty`.
319+ // `isDirty` is a structural deep-compare of the form values against the form defaults,
320+ // so empty arrays that field arrays (e.g. `responseValues.rows`) inject into the form
321+ // values on mount — but never into the defaults — make `isDirty` permanently `true`
322+ // even with no real changes. `dirtyFields` stays empty in that case, so it accurately
323+ // reflects whether there are unsaved user changes worth prompting about.
324+ const hasFormChanges = ! ! Object . keys ( dirtyFields ?? { } ) . length ;
318325 const {
319326 cancelNavigation : onCancelNavigation ,
320327 confirmNavigation,
321328 promptVisible,
322329 setPromptVisible,
323330 isLogoutInProgress,
324- } = usePrompt ( isDirty && ! hasAccessDeniedError ) ;
331+ } = usePrompt ( hasFormChanges && ! hasAccessDeniedError ) ;
325332 const shouldNavigateRef = useRef ( false ) ;
326333 const appletUniqueNameRef = useRef < string | null > ( null ) ;
327334 const { ownerId } = workspaces . useData ( ) || { } ;
You can’t perform that action at this time.
0 commit comments