Review main Merged

89756[BUGFIX] Avoid invalid events on initial render in property grid editor

Garvin Hicking CR +2 V +2 Easy +3 −3 updated 06/23/25, 12:58

Commit message

With #106485 the proper "dirtyness" checks of editing forms in the
backend UI was impacted so it recognized every form as "dirty" in
case a "Email to sender" or "Email to receiver" finisher was added.
The was caused by `<typo3-form-property-grid-editor>` pushing the
`PropertyGridEditorUpdateEvent` to subscribers not only on change,
but also on initialization.

Ensure that an update event is only dispatched if the value
of the entries change, not when they are initially set.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
    • Benjamin Kott +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Garvin Hicking +1
    • Benjamin Kott +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1618

  1. Garvin Hicking uploaded patch set 1 06/18/25, 12:45

  2. core-ci voted on patch set 1 V +1 06/18/25, 12:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/80466

  3. Benjamin Franzke uploaded patch set 2 V +1 06/19/25, 13:25

  4. Benjamin Franzke commented on patch set 2 06/19/25, 13:25

    Thanks for the showcase, I hope it's OK that I pushed over it and fixed the issue within the component (the cause, as mentioned in your sentence).
  5. core-ci voted on patch set 2 V +1 06/19/25, 13:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/80504

  6. Garvin Hicking commented on patch set 2 06/19/25, 14:26

    Reply

    Totally, always appreciated, never worry. 😊 Great you found the actual cause, that is much better. I'll test it tomorrow to verify.
  7. Garvin Hicking commented on patch set 2 V -1 06/19/25, 19:28

    Reply

    While this works for me to no longer show the modal in the described case, it also no longer shows the modal popup when I change the "description" field of a "select" input form type. In some cases it does register the "dirty state" properly, for example when I change an input fields "Label". Could it be it only recognizes dirty state if anything in the "middle" section of the form editor changes? Because 'description' does not change anything in the middle UI if changed, but 'label' does.
  8. Garvin Hicking commented on patch set 2 06/19/25, 19:29

    Reply

    (patchset1 actually also recognizes the dirty state in this scenario)
  9. Benjamin Franzke commented on patch set 2 06/20/25, 08:48

    Reply

    How should patchset 1 have detected that? It seems there's an event missing, so there is no property detection at all, patchset 1 "only" applied further constraints inside the dirty dection, but did not listen to "new" things, which are missing… I actually checked out patchset 1 again, and it does not work for the description field of "select" elements.
  10. Garvin Hicking commented on patch set 2 06/20/25, 09:21

    Reply

    > How should patchset 1 have detected that? The PS1 was a larger hammer hitting the nail and compared "old value" and "new value" before propagating the event, so that's why it caught differences in every field. I applied PS1 again via ``` git fetch ssh://ghi@review.typo3.org:29418/Packages/TYPO3.CMS refs/changes/56/89756/1 && git cherry-pick FETCH_HEAD ``` cleared the Browser-Cache and this results in this video: https://forge.typo3.org/attachments/39668 - the modal popup does appear to me, and doesn't in PS2. With PS2 it seems the whole event to propagate changes is no longer executed on fields that are are updated but not part of another event propagation chain to update the UI (which is not needed for this 'description' field)?
  11. Benjamin Franzke commented on patch set 2 06/20/25, 12:33

    Reply

    Understood, I had to debug to grasp that and seems I had a stale cache when testing patchset 1... It only worked because the `<typo3-form-property-grid-editor>` (the one that is only responsible for managing the nested entries for select options/finisher addresses, still dispatched a property change on initialization, but without the `_orig_*` values, and therefore the diff that patchset 1 implemented returned true (although not change had been performed yet) This happens as soon as the inspector pane of a select is opened (with patchset 1). ``` { _label: "d", _orig__label: {value: 'd', hmac: '…' }, _orig__value: {value: 'dd', hmac: '…'}, _value: "dd" } ``` New value: ``` { _label: "d", _value: "dd" } ``` Description change does not trigger an own signal then.. And that part seems tricky to fix, since the property watchers are added when the model is initializated from the initial dataset. (I actually do not understand why `@typo3/form/backend/form-editor/core` module does not respect configured editor fields, but only existing values in the factory function `createFormElement` – adding that could fix this issue, but it's complicated to understand side effects by such a change). Now, if the `elementDescription` is ommitted in the form.yaml definition, there is no initial property and therefore no event handler. I think we should handle that as a separate bug, since patchset 1 could only handle the description case because of the `<typo3-form-property-grid-editor>` behaving wrong. Take another example where patchset 1 can not fix the missing event handler for the `elementDescription` property: * Add a new text form element * Save * Select text element * Change description * Click Close button (no modal pops up)

    Reply

    OK I understand, but only because
  12. Benjamin Franzke commented on patch set 2 06/20/25, 12:34

    Reply

    > OK I understand, but only because nvm, I forgot to delete this draft.
  13. Garvin Hicking commented on patch set 2 CR +1 V +1 06/20/25, 12:52

    Reply

    Ack. I was not advocating that symptomatic PS1 would be a better approach, sorry if it came across as such. So do I understand right: 1.) We merge PS2 variant of the patch, so it will no longer spawn the dirty modal anymore 2.) Places where the dirty modal NEED to be spawned should be addressed in a follow-up That would be fine by me, voting as such. If you agree, feel free to merge this (or I will when another +1 comes in).
  14. Benjamin Franzke commented on patch set 2 06/23/25, 10:08

    Reply

    yes, we need to address that issue in a separate patch, but since dirty tracking only works for values that are actually set (or in other words, the form element "model" – described in https://docs.typo3.org/permalink/typo3-cms-form:concepts-formeditor-basicjavascriptconcepts-formelementmodel – works only for properties that have already been set, but not for new properties :\) Something like the following seems to work if we set this for every form element type – but that does not feel right and does not "scale" well, and writes a lot of empty values in every form that is saved: ``` prototypes: standard: formElementsDefinition: Text: formEditor: predefinedDefaults: properties.elementDescription: '' ```
  15. Benjamin Franzke commented on patch set 2 06/23/25, 10:50

    Reply

    Prepared a followup that uses the configured editors as a schema for event-publisher configurations to be applied upfront (before their value is even set): https://review.typo3.org/c/Packages/TYPO3.CMS/+/89793 Still need to understand impact/what can break, but I think that's the way to choose in order to fix our "sidequest" 😊 Anyway, we can merge here, once we find reviewers (I asked benji)
  16. Benjamin Kott voted on patch set 2 CR +1 V +1 06/23/25, 12:48

  17. Benjamin Franzke voted on patch set 2 CR +2 V +2 06/23/25, 12:48

  18. Benjamin Franzke merged patch set 3 06/23/25, 12:58