pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

Mod component shows as unsaved/dirty after clearing changes

Open twschiller opened this issue 1 year ago • 1 comments

Describe the bug

  • Mod component shows as unsaved/dirty after clearing changes
  • Discussion: https://pixiebrix.slack.com/archives/C0436P48QHY/p1729879942759189

To Reproduce

Steps to Reproduce:

  1. For an activated mod
  2. Change the name of a mod component in the Page Editor
  3. Click Clear Changes for the mod component

Actual behavior

The changes are cleared in the form state, but the component still shows a red disk icon

Expected behavior

The component does not show a red disk icon

Discussion

  • From the UI it looks like the mod component might be getting correctly set at clean and then getting marked as dirty
    • If you click Clear Changes on the mod and then click into the mod components, they also get marked as dirty. So I suspect for these mods there’s some useEffect normalization causing them to become dirty
  • If the editor is performing useEffects to normalize the state this is potentially the "correct" behavior in that the brick is being modified (although non-functionally) when the user clicks into it

Desktop (please complete the following information):

  • Extension Version: 2.1.6-beta.1

Related Code

  • https://github.com/pixiebrix/pixiebrix-extension/blob/e092de96b6bac94f96724e3a46e1dda306fcd3a8/src/pageEditor/hooks/useClearModComponentChanges.ts#L77-L77

twschiller avatar Oct 25 '24 18:10 twschiller

It's unclear how/why Formik is setting the form state (logs from turning on redux loggers diff feature):

image

This could be related to reinitializing the form instead of remounting

twschiller avatar Oct 26 '24 18:10 twschiller