Review main Merged

88774[BUGFIX] Render selected icon pane when at least one item has an icon

Stefan Bürk CR +2 V +2 Normal +62 −18 updated 03/27/25, 16:06

Commit message

The FormEngine renderType `selectSingle` can display a selected icon
on the left side of the select field.

`\TYPO3\CMS\Backend\Form\Element\SelectSingleElement` decides to render
the selected item conditionally by looping over all select items and
checking each item for a configured icon and sets the `$hasIcons` flag,
which is later used to decide, if the icon display should be rendered
at all, or not.

Further, if no selected icon has been found the first icon of the first
item of the first group is currently used as fallback, when having an
icon.

Looking onto the current implementation, following issues are revealed:

* The decision to render the selected icon pane left of the select
  field is soley made based on the last select item of last item
  group and not if at least one select item has an icon or not.

* If a item is selected, but has no icon defined the defined icon
  of the first item of the first group is used as fallback, which
  is considerable wrong. The fallback is intended to use that item
  only if no selection has been made.

* The `select icon` field wizard displays only the icons of items
  with a existing item, leaving items without an item out.

The last issue requires a greater decision related to UX handling
of that component and is not considered with this change and left
for a later general overwork of the component.

That means, this change itself concentrates on the first two issues,
which are resolvable with a overseable effort. To accomplish this,
this change:

* Uses the whole item array to track the selected state instead of
  the selected icon value to avoid a double meaning of empty string.

* Renders the selected icon pane left of the select field when at
  least one select item has a icon defined accomplished by setting
  the flag `$hasIcons` to true when an icon is found, but not to
  `false` in the other case. On top, the check is moved into the
  inner loop to check on each item of a group and not on the last
  item of a group.

* Modifies the fallback handling to use the first item icon of the
  first group only if no selected item is specified and no longer
  in case a selected item has no icon set, which also displayed the
  wrong item labels !!!.

That means, that for a selected without a icon no icon is displayed
left of the select field, but the box for the icon is there. This
matches the current behaviour, if the last item has an icon, but a
selected item which is not the last one is selected and has no icon.

The case with some items having icons and some not needs to be handled
in a dedicaded change and requires a general user-experience decision
how to deal with that, on the select field and the select icon wizard.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1725

  1. Stefan Bürk uploaded patch set 1 03/26/25, 13:41

  2. Stefan Bürk updated the commit message in patch set 2 03/26/25, 13:46

  3. core-ci voted on patch set 1 V +1 03/26/25, 13:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76383

  4. core-ci voted on patch set 2 V +1 03/26/25, 13:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76384

  5. Garvin Hicking commented on patch set 3 V +1 03/26/25, 17:41

    Published edit on patch set 2.
  6. core-ci voted on patch set 3 V +1 03/26/25, 17:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76395

  7. Garvin Hicking updated the commit message in patch set 4 V +1 03/26/25, 18:01

  8. core-ci voted on patch set 4 V +1 03/26/25, 18:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76397

  9. Garvin Hicking uploaded patch set 5 V +1 03/26/25, 18:29

  10. Garvin Hicking commented on patch set 5 V -1 03/26/25, 18:35

    That's a good catch. I believe this patch has a problem still. I added a styleguide example to easily test this. Check out select_single_22 and select_single_23 - the icon bar below does not list the entries without icons, and I would expect the items to show up with a "missing icon" prefix instead? Also, a selected item without an icon shows up with the broken image. If I switch to an icon, and then back to the itemless item, it will show an empty box instead of the 'missing icon' image (which I would expect). So I wonder if we should alter this patch to both: - When selecting an item with a missing icon, re-insert the "missing icon" placeholder in the select box placeholder (I believe the javascript does this) - insert a "missing icon" in the icon chooser pane so that values can be selected which do not have an icon What do you think?
  11. Garvin Hicking commented on patch set 5 03/26/25, 18:35

    tx_styleguide_elements_select.php:330

    Note this is intentionally "broken" to see have one case that can distinguish between "no image" and "broken image".
  12. core-ci voted on patch set 5 V +1 03/26/25, 18:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76399

  13. Stefan Bürk updated the commit message in patch set 6 V +1 03/26/25, 20:20

  14. Stefan Bürk voted on patch set 6 CR -1 03/26/25, 20:20

  15. Stefan Bürk commented on patch set 6 03/26/25, 20:23

    Reply

    What you mention is the fieldWizard added additionally, did not had that in view. Need to reconsider/think about that and will work/push something on top of that. Came back to reviwe that because during a walk in fresh air it bubbled up that the solution has another flaw beside what you mentioned. Thanks for looking into it and providing it as styleguide test. I did that with CType and adding a ctype plugin without an icon (had a extension locally laying around). Set to wip prefix and working on it.
  16. core-ci voted on patch set 6 V +1 03/26/25, 20:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76402

  17. Stefan Bürk uploaded patch set 7 CR -1 V +1 03/27/25, 09:42

  18. Stefan Bürk commented on patch set 7 03/27/25, 09:46

    Reply

    Looking into it again, it revealed even more. I adjusted the change, concentrating on: * decide displaying the pane on the fact when at least one item has an icon * ensure the first group item icon fallback is only when no item is selected, and not when the selected item has no icon. Which means, that items without icons displays no icon in the box left of the select box (staying empty) and are not selectable in the fieldWizard (bottom bar) like it is until now. I'd say that this needs a general UX decicision how to deal with it and how to determine a correct icon or making items without icon selectable in the field wizard and should not be done as a quick bugfix. The aim of this bugfix is and should stay to ensure that the pane is display when at least one item has an icon and is not hidden when the last item (of the last group) has no icon set and hiding it for all items. Not perfect, but improves the overall situation slightly.
  19. Stefan Bürk uploaded patch set 8 03/27/25, 09:49

  20. Stefan Bürk commented on patch set 7 03/27/25, 09:50

    tx_styleguide_elements_select.php:330 Reply

    Added as comment in the TCA file.
  21. core-ci voted on patch set 7 V +1 03/27/25, 09:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76428

  22. core-ci voted on patch set 8 V +1 03/27/25, 09:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76429

  23. Benni Mack voted on patch set 8 CR +1 V +1 03/27/25, 14:21

  24. Georg Ringer voted on patch set 8 CR +2 V +2 03/27/25, 16:06

  25. Georg Ringer merged patch set 9 03/27/25, 16:06