Postponed on #3083256: Create smaller variations for form elements
Problem/Motivation
Claro automatically sets operations dropbuttons to '#type' => 'extrasmall'. If the operations dropbutton is accompanied by other form elements, those form elements will still be at their default size, and the form elements will not have inconsistent sizes.
When #3083256: Create smaller variations for form elements is added to core, the form--small and form--extrasmall classes will be made available. Wrapping a form in these classes will results in all form elements taking on their small/extrasmall variants, and eliminate the issue of inconsistent sizes.
Steps to reproduce
>
Proposed resolution
Find the best way to wrap forms with operations dropbuttons in form--extrasmall.
If the method used is comprehensive enough, also remove the prerender enforcing the extrasmall variant for operations dropbuttons,
in ClaroPreRender
/**
* Prerender callback for the Operations element.
*/
public static function operations($element) {
if (empty($element['#dropbutton_type'])) {
$element['#dropbutton_type'] = 'extrasmall';
}
return $element;
}In claro.theme
// Add a pre-render function for Operations to set #dropbutton_type.
if (isset($type['operations'])) {
// In Claro, Operations should always use the extrasmall dropbutton variant.
// To add CSS classes based on variants, the element must have the
// #dropbutton_type property before it is processed by
// \Drupal\Core\Render\Element\Dropbutton::preRenderDropbutton(). This
// ensures #dropbutton_type is available to preRenderDropbutton().
$operations_pre_renders = !empty($type['operations']['#pre_render']) ? $type['operations']['#pre_render'] : [];
array_unshift($operations_pre_renders, [ClaroPreRender::class, 'operations']);
$type['operations']['#pre_render'] = $operations_pre_renders;
}Remaining tasks
After implementing, address any @todo items referencing this issue.
Comments
Comment #2
bnjmnmComment #3
bnjmnm