Review main Merged

86646[TASK] Feed `@typo3/backend/form-engine-review` from events

Andreas Kienast CR +2 V +2 Normal +34 −25 updated 10/21/24, 20:00

Commit message

The behavior of the `@typo3/backend/form-engine-review` module has been
modernized.

The `t3-formengine-postfieldvalidation` event now gets the affected
field and its validity status passed, which is consumed in the review
module instead of scraping the DOM all over again.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Oli Bartsch +1
    • Ayke Halder +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Oli Bartsch +1
    • Ayke Halder +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 1419

  1. Andreas Kienast uploaded patch set 1 10/18/24, 10:05

  2. core-ci voted on patch set 1 V -1 10/18/24, 10:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67949

  3. Andreas Kienast uploaded patch set 2 V -1 10/18/24, 10:30

  4. core-ci voted on patch set 2 V +1 10/18/24, 10:36 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67950

  5. Andreas Kienast updated the commit message in patch set 3 V +1 10/21/24, 05:41

  6. core-ci voted on patch set 3 V +1 10/21/24, 05:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68278

  7. Andreas Kienast uploaded patch set 4 V +1 10/21/24, 09:07

  8. core-ci voted on patch set 4 V +1 10/21/24, 09:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68290

  9. Oli Bartsch voted on patch set 4 CR +1 V +1 10/21/24, 09:15

  10. Ayke Halder commented on patch set 4 10/21/24, 13:59

    How about starting with keeping `strictNullChecks` in mind?

    form-engine-review.ts:96

    `querySelector(…)` might actually return `null` on run-time if no element is found. Whereas the code right now tells TypeScript that there is always an object of type `HTMLElement` to be found. ``` const relatedInputField = fieldContainer.querySelector(…) as HTMLElement; ``` Better use the following code, as this tells TypeScript that the returned object is of type `HTMLElement|null` - so might also be null: ``` const relatedInputField = fieldContainer.querySelector<HTMLElement>(…); ``` ---- You can temporarily activate `strictNullChecks` in `Build/tsconfig.json`: ```json { "compilerOptions": { "strictNullChecks": true, … }, … } ```
  11. Andreas Kienast commented on patch set 4 10/21/24, 14:08

    Reply

    There's a pending patch from Benjamin Franzke that's WIP right now.

    form-engine-review.ts:96 Reply

    I get the intention of your comment and I appreciate it. However, if this code breaks, something is heavily broken in FormEngine which I explicitly want to fail.
  12. Ayke Halder commented on patch set 4 10/21/24, 14:28

    form-engine-review.ts:96 Reply

    I get your point. And in case you deliberately want the code to break on run-time if anything is unexpectedly `null`, use the "non-null assertion operator": https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator Syntax is like `someObject!`: * `fieldContainer!.querySelector(…)` * `this.switchToField(e, relatedInputField!)` E.g. the code could be like this: ``` for (const invalidField of this.invalidFields) { const fieldContainer = invalidField.closest('.t3js-formengine-validation-marker'); const relatedInputField = fieldContainer!.querySelector<HTMLElement>('[data-formengine-validation-rules]'); const link = document.createElement('a'); link.classList.add('list-group-item'); link.href = '#'; link.textContent = fieldContainer!.querySelector(this.labelSelector)?.textContent || ''; link.addEventListener('click', (e: Event) => this.switchToField(e, relatedInputField!)); erroneousListGroup.append(link); } ```
  13. Andreas Kienast uploaded patch set 5 CR +1 V +1 10/21/24, 14:44

  14. core-ci voted on patch set 5 V +1 10/21/24, 14:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68319

  15. Andreas Kienast commented on patch set 5 10/21/24, 14:52

    form-engine-review.ts:96 Reply

    Done
  16. Oli Bartsch voted on patch set 5 CR +1 V +1 10/21/24, 14:55

  17. Ayke Halder voted on patch set 5 CR +1 V +1 10/21/24, 15:12

  18. Andreas Kienast voted on patch set 5 CR +2 V +2 10/21/24, 20:00

  19. Andreas Kienast merged patch set 6 10/21/24, 20:00