#98354colClear for colums in TCA palettes with numberOfItems > 4
Description
I had 7 fields of type checkbox within a palette. The items have been arranged in two columns – but why?
The calculation is done in \TYPO3\CMS\Backend\Form\Container\PaletteAndSingleContainer::renderInnerPaletteContent() by `$colWidth = (int)floor(12 / $numberOfItems);`.
Let’s calculate some values:
numberOfItems: 1 - colWidth: 12 numberOfItems: 2 - colWidth: 6 numberOfItems: 3 - colWidth: 4 numberOfItems: 4 - colWidth: 3 numberOfItems: 5 - colWidth: 2 numberOfItems: 6 - colWidth: 2 numberOfItems: 7 - colWidth: 1 numberOfItems: 8 - colWidth: 1 numberOfItems: 9 - colWidth: 1 numberOfItems: 10 - colWidth: 1 numberOfItems: 11 - colWidth: 1 numberOfItems: 12 - colWidth: 1
For all $numberOfItems > 4, you’ll get $colWidth <= 2 with results in CSS classes “col-sm-6 col-md-3 col-lg-2”. For large screens we’ll have 6 columns.
But … There’s a logic for ‘colClear’-elements, too. These are inserted (for $colWidth <= 2) after each second, fourth and sixth item. With these clearers the behavior of colWidth brakes: e.g. 7 items are arranged in 6 columns, each with width 16,77%, but due to the colClear-elements the output is only two-columned.
I’m not sure if it’s really a bug, because someone obviously gave some thought to the introduction of the colClear elements, but I see potential for optimization.
Tested in TYPO3 v11. Code seems unchanged in v12/master
Reviews 3
Related issues 1
Files 6
History 1222
-
Garvin Hicking commented and changed category status
NewNeeds Feedback Tags responsive, ux Sprint Focus Needs Decision <span data-processor="relativetime" data-value="2024-06-20T07:10:01+00:00" > 06/20/24, 07:10 </span>The behaviour is the same for v13. I guess for that many elements, having a two-column grid was meant to not be overwhelmed by the items and support a simpler “list view” for the human eye.
Maybe the UX team wants to weigh in.
(Markus’ patch can still apply to v13main and only needs a minor merge conflict resolve, but honestly I don’t feel like having that many checkboxes/input elements next to each other is visually appealing…?)
-
Julian Hofmann commented <span data-processor="relativetime" data-value="2024-06-20T10:40:45+00:00" > 06/20/24, 10:40 </span>
However, more than 4 checkboxes quickly result – especially with (customer-specific) data records.
Think, for example, of allergens contained in food, the topping of a pizza, properties of a property,…
Yes, it is possible to pack all these properties into separate fields. But then their (joint) filtering becomes more complex – and whether the UX in the backend would be better is questionable.
-
Garvin Hicking commented <span data-processor="relativetime" data-value="2024-06-20T12:07:46+00:00" > 06/20/24, 12:07 </span>
Wouldn’t for this usecase a category tree be more helpful and workable? Or a custom rendertype even, arranging it exactly as needed?
-
Julian Hofmann commented <span data-processor="relativetime" data-value="2024-06-20T14:25:29+00:00" > 06/20/24, 14:25 </span>
A category tree requires a tree-like data structure. Checkboxes are at the same level.
A separate rendertype would also be a solution, yes, maybe.Nevertheless, I question the formatting behavior of the core. In my opinion, it is broken – regardless of whether more than 4 checkboxes “make sense”.
> For all $numberOfItems > 4, you’ll get $colWidth <= 2 with results in CSS classes “col-sm-6 col-md-3 col-lg-2”. For large screens we’ll have 6 columns.
Summary
>
> But … There’s a logic for ‘colClear’-elements, too. These are inserted (for $colWidth <= 2) after each second, fourth and sixth item. With these clearers the behavior of colWidth brakes: e.g. 7 items are arranged in 6 columns, each with width 16,77%, but due to the colClear-elements the output is only two-columned.- If a two-column layout is forced (via `colClear`), then the full width should still be used (i.e. 50% per item).
- Or – if you set the 16.77% width per item – a corresponding number of items should be arranged next to each other.
-
Garvin Hicking commented and changed status
Needs FeedbackNew <span data-processor="relativetime" data-value="2024-06-20T15:42:33+00:00" > 06/20/24, 15:42 </span>Julian Hofmann wrote in #note-5:
> A category tree requires a tree-like data structure. Checkboxes are at the same level.I was thinking about your idea with the pizza toppings, allergens, etc – these could all be attributes specified in a tree, but sorry if I misstepped.
> Nevertheless, I question the formatting behavior of the core. In my opinion, it is broken – regardless of whether more than 4 checkboxes “make sense”.
OK! I’ll leave this ticket as “Needs decision” for someone of the Backend UI/UX/Accessibility-Team, thanks for elaborating!
-
Armin Vieweg commented <span data-processor="relativetime" data-value="2024-08-08T09:24:11+00:00" > 08/08/24, 09:24 </span>
I’ve also recognized this behavior and think that it is not intended to interrupt the grid system with clearfixes, this way.
I think this is a relict from migration to Bootstrap.
In my opinion, the clearfixes should get removed entirely, because Bootstrap Grids doesn’t work like that.
Also, it would be possible to add “col” class only for every field in palette, the Bootstrap grid will choose and align the size of each column on its own. This would also make the current calculation of column size obsolete.
For —linebreak— a new row should be added, instead of using “dirty” clearfix.
-
Gerrit Code Review pushed patch set 1 for main to change 85556 status
NewUnder Review <span data-processor="relativetime" data-value="2024-08-08T12:26:53+00:00" > 08/08/24, 12:26 </span> -
Armin Vieweg commented and changed attached clipboard-202408081428-bsfm6.png attached clipboard-202408081429-7tstp.png attached clipboard-202408081429-nztlq.png attached clipboard-202408081429-isoe9.png <span data-processor="relativetime" data-value="2024-08-08T12:30:40+00:00" > 08/08/24, 12:30 </span>
With the patch, palette fields behave like this:
clipboard-202408081428-bsfm6.png
clipboard-202408081429-7tstp.png
clipboard-202408081429-nztlq.png
The space behind “Field 10” happens, because of defined max-width in every form field.
-
Gerrit Code Review pushed patch set 2 for main to change 85556 <span data-processor="relativetime" data-value="2024-10-18T13:44:16+00:00" > 10/18/24, 13:44 </span>
-
Gerrit Code Review pushed patch set 3 for main to change 85556 <span data-processor="relativetime" data-value="2024-10-28T15:40:45+00:00" > 10/28/24, 15:40 </span>
-
Gerrit Code Review pushed patch set 4 for main to change 85556 <span data-processor="relativetime" data-value="2024-11-02T10:09:39+00:00" > 11/02/24, 10:09 </span>
-
Garvin Hicking commented and changed attached Screenshot 2024-11-02 at 11.09.08.png attached Screenshot 2024-11-02 at 11.10.44.png <span data-processor="relativetime" data-value="2024-11-02T10:13:02+00:00" > 11/02/24, 10:13 </span>
Screenshots of EXT:styleguide example
With patch:
!Screenshot 2024-11-02 at 11.09.08.png!Without patch:
!Screenshot 2024-11-02 at 11.10.44.png! -
Gerrit Code Review pushed patch set 5 for main to change 85556 <span data-processor="relativetime" data-value="2024-11-05T10:20:04+00:00" > 11/05/24, 10:20 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 86918 <span data-processor="relativetime" data-value="2024-11-07T13:44:11+00:00" > 11/07/24, 13:44 </span>
-
Gerrit Code Review pushed patch set 6 for main to change 85556 <span data-processor="relativetime" data-value="2024-11-07T13:47:17+00:00" > 11/07/24, 13:47 </span>
-
Gerrit Code Review pushed patch set 7 for main to change 85556 <span data-processor="relativetime" data-value="2024-11-07T14:44:56+00:00" > 11/07/24, 14:44 </span>
-
Gerrit Code Review pushed patch set 8 for main to change 85556 <span data-processor="relativetime" data-value="2024-11-08T13:42:29+00:00" > 11/08/24, 13:42 </span>
-
Gerrit Code Review pushed patch set 9 for main to change 85556 <span data-processor="relativetime" data-value="2025-03-28T11:44:04+00:00" > 03/28/25, 11:44 </span>
-
Markus Klein changed status
Under ReviewNew <span data-processor="relativetime" data-value="2025-04-22T10:48:26+00:00" > 04/22/25, 10:48 </span> -
Nikita Hovratov changed Related to #108253 <span data-processor="relativetime" data-value="2025-11-22T12:05:48+00:00" > 11/22/25, 12:05 </span>
-
Georg Ringer commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-10-06T19:28:02+00:00" > 10/06/26, 19:28 </span>IMO fixed with #108253. if this is still valid for you in v14, please open a new issue with information how to reproduce it. thanks
Maybe our attempt https://review.typo3.org/c/Packages/TYPO3.CMS/+/76877 is a possible way to go?