Review main Merged

83643[TASK] Deprecate `@typo3/backend/document-save-actions`

Andreas Kienast CR +2 V +2 Normal +189 −9 updated 04/05/24, 14:26

Commit message

The JavaScript module `@typo3/backend/document-save-actions` was
introduced in TYPO3 v7 to add some interactivity in FormEngine context.
At first it was only used to disable the submit button and render a
spinner icon instead. Over the course of some years, the module got more
functionality.

After some refactorings within FormEngine, the module became rather a
burden. This became visible with the introduction of the Hotkeys API, as
the `@typo3/backend/document-save-actions` module reacts on explicit
`click` events on the save icon, that is not triggered when FormEngine
invokes a save action via keyboard shortcuts.

Adjusting `document-save-actions`'s behavior is necessary here, but
would become a breaking change, which is unacceptable after the 13.0
release. For this reason, said module has been marked as deprecated and
its usages are replaced by its successor
`@typo3/backend/form/submit-interceptor`.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 9

Review log 1924

  1. Andreas Kienast uploaded patch set 1 04/03/24, 14:02

  2. core-ci voted on patch set 1 V -1 04/03/24, 14:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55266

  3. Andreas Kienast uploaded patch set 2 V -1 04/03/24, 14:19

  4. Andreas Kienast uploaded patch set 3 04/03/24, 14:20

  5. core-ci voted on patch set 2 V +1 04/03/24, 14:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55268

  6. core-ci voted on patch set 3 V +1 04/03/24, 14:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55269

  7. Garvin Hicking uploaded patch set 4 V +1 04/03/24, 16:15

    docs
  8. core-ci voted on patch set 4 V +1 04/03/24, 16:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55274

  9. Garvin Hicking commented on patch set 4 CR +1 V +1 04/03/24, 16:20

    The scheduler doesn't yet feature the "Cmd+S" save action and I wonder if it should (maybe outside the scope of this PR of course)? Rest seems to work well also in conjunction with 83642 for me, tested a few variants (saving with/without keyboard, having validation kick in on empty fields) in macOS Chromium+FF.
  10. Andreas Kienast commented on patch set 4 04/03/24, 16:44

    Reply

    Absolutely, scheduler (and EXT:form) should make use of shortcuts as well.
  11. Simon Schaufelberger commented on patch set 4 04/03/24, 23:06

    submit-interceptor.ts:54

    I would prefer early return here as there is no code after that and it would make the code more readable without deep nesting.

    Deprecation-103528-DeprecatedDocumentSaveActionsModule.rst:29

    2 empty lines should be enough
  12. Andreas Kienast commented on patch set 4 04/04/24, 05:46

    submit-interceptor.ts:54 Reply

    I don't see how this improves readability. Also, guard-clauses should be used to avoid the execution of methods as a whole.

    Deprecation-103528-DeprecatedDocumentSaveActionsModule.rst:29 Reply

    Acknowledged
  13. Andreas Kienast commented on patch set 5 CR +1 V +1 04/04/24, 05:46

    Published edit on patch set 4.
  14. core-ci voted on patch set 5 V +1 04/04/24, 05:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/55311

  15. Garvin Hicking voted on patch set 5 CR +1 V +1 04/04/24, 05:58

  16. Simon Schaufelberger voted on patch set 5 CR +1 04/05/24, 08:59

  17. Simon Schaufelberger commented on patch set 5 CR 0 04/05/24, 09:02

    submit-interceptor.ts:54

    how about: ``` if (e.submitter === null) { return; } if (e.submitter instanceof HTMLInputElement || e.submitter instanceof HTMLButtonElement) { e.submitter.disabled = true; } Icons.getIcon('spinner-circle', Icons.sizes.small).then((markup: string): void => { e.submitter.replaceChild(document.createRange().createContextualFragment(markup), e.submitter.querySelector('.t3js-icon')); }).catch(() => { // Catch error in case the promise was not resolved // e.g. loading a new page }); ```
  18. Andreas Kienast commented on patch set 5 04/05/24, 09:43

    submit-interceptor.ts:54 Reply

    Sorry, IMO this clutters the code even more.
  19. Simon Schaufelberger commented on patch set 5 04/05/24, 11:55

    submit-interceptor.ts:54 Reply

    imo it's much more readable as the main logic is not nested but on first level.
  20. Simon Schaufelberger commented on patch set 5 04/05/24, 11:56

    submit-interceptor.ts:54 Reply

    this is also how we write our rector rules.
  21. Garvin Hicking commented on patch set 5 04/05/24, 13:16

    submit-interceptor.ts:54 Reply

    Code style discussions can often be a matter of taste, maybe we can break the cycle here. Since this affects JavaScript code that mostly Andreas and colleagues maintain, please let them pick their way of best readibility. Those who do the main work in that domain should IMO get that freedom to pick best formatting/logic sections for their work. (I understand in rector and for your work early returns work better for you, and that's your authoritative domain!)
  22. Simon Schaufelberger commented on patch set 5 CR +1 04/05/24, 14:22

    submit-interceptor.ts:54 Reply

    This shouldn't be a blocker or something, I just wanted to ask if he would agree to write it differently. My intention was not to tell him: Please do it like this but more like: What do you think about this way?
  23. Stefan Bürk voted on patch set 5 CR +2 V +2 04/05/24, 14:26

  24. Stefan Bürk merged patch set 6 04/05/24, 14:26