Review main Abandoned Breaking

81612[!!!][TASK] Offload null value checkbox handling from JavaScript

Andreas Kienast CR 0 V 0 Hard +221 −64 updated 01/26/24, 07:47

Commit message

Previously, the FormEngine JavaScript iterated over all controls that
relate to TCA's `'nullable'` option, allowing to explicitly set a
field's value to `NULL`, to set the form field states (either disabled
or toggled, in case placeholders are used). Defining the states via
JavaScript may cause lags in the initial rendering as the DOM needs to
be fully loaded. Also, the full initialization is repeated sometimes,
e.g. when a new IRRE section is added.

To overcome these issues, the states are now defined in FormEnine's
form elements and any initialization code has been removed from
FormEngine JavaScript.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 11

Review log 1825

  1. Andreas Kienast uploaded patch set 1 10/30/23, 10:44

  2. core-ci voted on patch set 1 V +1 10/30/23, 10:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48350

  3. Andreas Kienast uploaded patch set 2 V +1 10/30/23, 11:46

  4. core-ci voted on patch set 2 V +1 10/30/23, 11:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48353

  5. Andreas Kienast uploaded patch set 3 V +1 10/30/23, 13:45

  6. core-ci voted on patch set 3 V +1 10/30/23, 13:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48356

  7. Garvin Hicking commented on patch set 3 10/30/23, 13:57

    Breaking-102287-OffloadNullValueCheckboxStateRenderingFromJavaScript.rst:39

    It would be cool to link to an example as performed for the core TCA files for a more "visual" example, i.e. a notice like: "See the changes related to this commit." (I suppose this is a chicken-egg issue because you can't link to a github link before this is merged). So maybe an inline diff at this point would help, taking a form element like `InputTextElement` and showing it here before/after?
  8. Andreas Kienast commented on patch set 3 10/30/23, 14:00

    Breaking-102287-OffloadNullValueCheckboxStateRenderingFromJavaScript.rst:39 Reply

    I also thought about that, let's see if I can work this out somehow.
  9. Andreas Kienast uploaded patch set 4 V +1 10/30/23, 14:07

  10. Garvin Hicking commented on patch set 4 10/30/23, 14:08

    Breaking-102287-OffloadNullValueCheckboxStateRenderingFromJavaScript.rst:39 Reply

    Works for me, that's very helpful.
  11. Andreas Kienast uploaded patch set 5 10/30/23, 14:09

  12. core-ci voted on patch set 4 V +1 10/30/23, 14:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48357

  13. core-ci voted on patch set 5 V +1 10/30/23, 14:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48358

  14. Garvin Hicking commented on patch set 5 10/30/23, 14:35

    ColorElement.php:238

    Check above was made with strict (=== '') comparison, maybe use this here too for uniformity? (also applies to all other RenderTypes)
  15. Andreas Kienast commented on patch set 5 10/30/23, 14:38

    ColorElement.php:238 Reply

    Fair enough
  16. Andreas Kienast uploaded patch set 6 V +1 10/30/23, 14:45

  17. Andreas Kienast commented on patch set 6 10/30/23, 14:45

    ColorElement.php:238 Reply

    Done
  18. core-ci voted on patch set 6 V +1 10/30/23, 14:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48361

  19. Andreas Kienast uploaded patch set 7 V +1 10/31/23, 05:50

  20. core-ci voted on patch set 7 V +1 10/31/23, 05:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/48378

  21. Garvin Hicking commented on patch set 7 10/31/23, 09:12

    Tested this some more. Works as advertised... however: May I suggest adding a block like this to the section "Migration": ``` You can find custom extensions registering custom FormElements by searching for GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'] in ext_localconf.php. While a custom FormElement is not adapted to the new syntax, the input area for a saved NULL value will NOT be greyed out and disabled. That leads to any input getting entered in this state will not be persisted, because the corresponding checkbox would be unchecked. By checking the `Set value` checkbox in this unadapted state, no values could be entered. Thus: without adaptation, the nullable checkbox logic would be reversed. ``` I must admit that having this logic applied to unadapted form fields is a bit dangerous due to the logic reversal and may lead to data loss when saving. So I wonder if we could "do more" for integrators to catch this. How about the adapted core fields add a specific CSS class like `t3js-formengine-nullable-support`. Then, the JS would only properly operate on fields having said class. And if the JS would toggle the state in unadapted fields, we could present an alert/warning like "Custom FormElement is nullable, but has not been adapted to proper syntax". This wouldn't be a real "migration" then, since it only depends on a CSS class that would not need to be removed anytime, and would provide stability? Especially because the Scanner isn't able to detect custom FormElement nullable usage and warn about it...?
  22. Andreas Kienast commented on patch set 7 CR -2 10/31/23, 09:59

    Reply

    Data loss is something we must avoid under any circumstance. I'll think about the whole approach, maybe I'll come up with something better.
  23. Simon Schaufelberger commented on patch set 7 01/25/24, 14:26

    Reply

    @a.fernandez@scripting-base.de Will this make it for v13?
  24. Andreas Kienast commented on patch set 7 01/26/24, 07:47

    Reply

    Definitely not. v13.0 release is next Tuesday and FormEngine would need more refactoring in that regard. Abandoning for now.
  25. Andreas Kienast abandoned the change 01/26/24, 07:47