Review main Merged

86914[BUGFIX] Add color preview for color field

Dennis Purisevic CR +2 V +2 Hard +254 −152 updated 01/16/25, 15:15

Commit message

This adds missing color preview for color pickers in FormEngine,
TypoScript constants and in Site and Extensions Settings.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 17

Review log 3443

Show 1318 earlier messages
  1. Dennis Purisevic uploaded patch set 1 11/07/24, 10:57

  2. core-ci voted on patch set 1 V +1 11/07/24, 11:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69178

  3. Dennis Purisevic uploaded patch set 2 V +1 11/07/24, 18:39

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

  5. Oli Bartsch commented on patch set 2 11/08/24, 08:15

    Hi, thanks a lot for your patch! I've also worked on this issue, see https://review.typo3.org/c/Packages/TYPO3.CMS/+/86914. However, I think your patch is way better and therefore abandoned mine. I already tested yours and it works quite well. There is however a place not covered yet. The site settings module also allows to choose a color, we should therefore also add the preview to this component: https://github.com/TYPO3/typo3/blob/main/Build/Sources/TypeScript/backend/settings/type/color.ts.
  6. Dennis Purisevic uploaded patch set 3 V +1 11/08/24, 09:38

  7. core-ci voted on patch set 3 V +1 11/08/24, 09:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69225

  8. Dennis Purisevic commented on patch set 3 11/08/24, 10:29

    Reply

    Hey, thanks for your feedback. I saw your patch as well and optimized my code accordingly. I’ve adjusted the Site Settings module, and it should be working now. Thanks for pointing it out!
  9. Oli Bartsch commented on patch set 3 CR +1 V +1 11/08/24, 10:44

    Reply

    Thanks for the fast adjustments. Works good!
  10. Simon Schaufelberger commented on patch set 3 11/08/24, 10:50

    ConstantEditorFields.html:174

    'color' in quotes as it is not a variable, or?
  11. Benjamin Franzke commented on patch set 3 CR -1 11/08/24, 10:51

    color.ts:42

    This removes the handler that updates the form-value. That means updates will not be stored. Important info: `ColorTypeElement` provides the value to the settings form and therefore needs to sync from the underlying input element.
  12. Oli Bartsch commented on patch set 3 CR 0 V -1 11/08/24, 10:52

    Reply

    Unfortunately I found a bug. Initially and on fields without a value the preview now renders a black color preview instead of the "transparent".
  13. Dennis Purisevic uploaded patch set 4 CR -1 V +1 11/08/24, 17:28

  14. Dennis Purisevic commented on patch set 4 11/08/24, 17:34

    Reply

    Found the bug and made an update to that. Now if the field is empty the preview is always "transparent".

    color.ts:42 Reply

    Checked it and made an update. Should now work as intended.

    ConstantEditorFields.html:174 Reply

    Checked with the documentation and current implementation of <f:if> and you are right. I've made adjustments to the line.
  15. core-ci voted on patch set 4 V -1 11/08/24, 17:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69237

  16. Dennis Purisevic uploaded patch set 5 V -1 11/08/24, 20:28

  17. core-ci voted on patch set 5 V +1 11/08/24, 20:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69238

  18. Simon Schaufelberger commented on patch set 5 11/08/24, 21:19

    color-preview.ts:16

    this is not TYPO3 code style. Please close the comment with just one asterisk

    color-preview.ts:31

    this is not TYPO3 code style. Please close the comment with just one asterisk
  1. Dennis Purisevic uploaded patch set 6 V +1 11/08/24, 22:01

  2. Dennis Purisevic commented on patch set 6 11/08/24, 22:01

    color-preview.ts:16 Reply

    Done

    color-preview.ts:31 Reply

    Done
  3. core-ci voted on patch set 6 V +1 11/08/24, 22:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69239

  4. Oli Bartsch uploaded patch set 7 V +1 11/09/24, 09:54

  5. Oli Bartsch voted on patch set 7 CR +1 V +1 11/09/24, 09:55

  6. core-ci voted on patch set 7 V +1 11/09/24, 10:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69253

  7. Garvin Hicking commented on patch set 7 V +1 11/11/24, 09:22

    Works quite well, this is a great enhancement, thanks! With the current code we have a bit of redundancy due to https://review.typo3.org/c/Packages/TYPO3.CMS/+/86914/7/typo3/sysext/backend/Classes/Form/Element/ColorElement.php#99 and https://review.typo3.org/c/Packages/TYPO3.CMS/+/86914/7/typo3/sysext/tstemplate/Resources/Private/Partials/ConstantEditorFields.html#174 basically doing the same like the JS counterpart https://review.typo3.org/c/Packages/TYPO3.CMS/+/86914/7/Build/Sources/TypeScript/backend/form-engine/element/extra/color-preview.ts#21 Since I'm not too deep into the webcomponents/JS and how it best suits Formengine, I guess it needs to be like this?
  8. Benjamin Franzke commented on patch set 7 CR -1 11/11/24, 09:29

    color.ts:18

    I don't want settings to import from form-engine code. I'd rather keep them separate. Will move color-preview into color-picker.
  9. Benjamin Franzke uploaded patch set 8 CR +1 V +1 11/11/24, 09:34

  10. Benjamin Franzke commented on patch set 8 11/11/24, 09:34

    color.ts:18 Reply

    Done
  11. Oli Bartsch voted on patch set 8 CR +1 V +1 11/11/24, 09:43

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

  13. Andreas Kienast commented on patch set 8 V -1 11/11/24, 10:00

    _input-group.scss:47

    This breaks with right-to-left backends.
  14. Benjamin Franzke commented on patch set 8 11/11/24, 10:01

    Sorry, we need to polish this a bit. found some issues

    _colorpicker.scss:438

    t3js is not to be used for styling

    _form-group.scss:7

    Should be defined for `.form-control` (and not use t3js)

    _input-group.scss:44

    Should detect input-groups (or try to avoid those workarounds) instead of hardcoding cases.

    color-picker.ts:33

    This should ideally be server rendered as a markup-contract, and for site settings rendered via the color-type settings component. (Or we transform color-picker into a web component with a stable API)
  15. Oli Bartsch voted on patch set 8 CR 0 V 0 11/11/24, 10:03

  16. Dennis Purisevic commented on patch set 8 11/11/24, 11:15

    _colorpicker.scss:438 Reply

    Would just ".colorpicker-preview-color" be better and ".t3js-colorpicker-preview-color" just for js?

    _form-group.scss:7 Reply

    Acknowledged

    _input-group.scss:44 Reply

    Acknowledged

    _input-group.scss:47 Reply

    Acknowledged

    color-picker.ts:33 Reply

    I think a web component would be good. It could remove some of the duplicate code in https://github.com/TYPO3/typo3/blob/main/Build/Sources/TypeScript/backend/settings/type/color.ts and https://github.com/TYPO3/typo3/blob/main/Build/Sources/TypeScript/backend/color-picker.ts and would streamline the overall usage of the color input. I will take a look into that later today.
  17. Dennis Purisevic uploaded patch set 9 V +1 11/12/24, 07:49

  18. core-ci voted on patch set 9 V +1 11/12/24, 07:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69346

  19. Dennis Purisevic commented on patch set 9 11/13/24, 10:53

    _colorpicker.scss:438 Reply

    Done

    color-picker.ts:33 Reply

    Done
  20. Garvin Hicking commented on patch set 9 V +1 12/09/24, 12:56

    Seems to work for me in current state, sadly I can't comment too much on the JS-side of things. I would guess instead of: ``` <typo3-backend-color-picker> <input type="text" id=${this.formid} class="form-control" ... </typo3-backend-color-picker> ``` it should probably rather be used like this: ``` <typo3-backend-color-picker type="text" id=${this.formid} class="form-control" ... </typo3-backend-color-picker> ``` so that the webcomponent takes care of emitting the input element? Not sure what in the DOM then could possibly break or be inaccessible.
  21. Oli Bartsch voted on patch set 9 CR +1 V +1 12/16/24, 08:50

  22. Garvin Hicking commented on patch set 9 CR +1 12/16/24, 09:34

    (After some talk with Oli about this I agree we
  23. Oli Bartsch commented on patch set 9 CR +2 V +2 12/16/24, 09:52

    @dennispurisevic@gmail.com Thank you really much for this bugfix!
  24. Oli Bartsch merged patch set 10 12/16/24, 09:52

  25. Nikita Hovratov commented on patch set 10 01/16/25, 15:15

    This patch was breaking for consumers of @typo3/backend/color-picker module. See Mask extension e.g.: https://github.com/Gernott/mask/issues/660