There are a couple of issues with the way we handle units right now. Themes provide the available themes by adding spacing.units to their theme.json or by defining add_theme_support( 'custom-units' )
I noticed a number of issues though:
If the theme doesn't define anything, we end up with false value for the config but since we have fallbacks each time we do useSetting( 'spacing.units' ) in core blocks, it means we'll still allow custom units. I guess that means custom units are opt-out these days, that's fine but we should clarify how themes can opt-out of custom units and if that's even something we allow.
The other point is that if a theme removes % from the available units, it is still possible to use a pattern or a variation with that unit (for instance columns variations), Right now, the block works well but the UI in the inspector shows another unit as selected, maybe we should show the unit but disabled?
The third item I noted is that right now it's too complex for blocks to use the units config, a fallback is necessary and a call to an experimental useCustomUnits hook is needed, I think ideally we should simplify that and just pass useSetting( 'spacing.units' ) as a prop to the UI component. Some refactoring/simplification might be needed there.
There are a couple of issues with the way we handle units right now. Themes provide the available themes by adding
spacing.units
to theirtheme.json
or by definingadd_theme_support( 'custom-units' )
I noticed a number of issues though:
false
value for the config but since we have fallbacks each time we douseSetting( 'spacing.units' )
in core blocks, it means we'll still allow custom units. I guess that means custom units are opt-out these days, that's fine but we should clarify how themes can opt-out of custom units and if that's even something we allow.%
from the available units, it is still possible to use a pattern or a variation with that unit (for instance columns variations), Right now, the block works well but the UI in the inspector shows another unit as selected, maybe we should show the unit but disabled?useSetting( 'spacing.units' )
as a prop to the UI component. Some refactoring/simplification might be needed there.cc @nosolosw @aristath
The text was updated successfully, but these errors were encountered: