Skip to content

Commit b1584d4

Browse files
Allow end-positioning a drop-down menu (#5061)
1 parent d78c912 commit b1584d4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

themes/bootstrap5/templates/_ui/components/menu-button.phtml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @param string $toggleLabel The label for the toggle button (will be translated)
1414
* @param ?string $wrapperTag Tag to use as a wrapper around the control (default = div)
1515
* @param ?string $wrapperClass Extra CSS class(es) to apply to the wrapper tag
16+
* @param ?string $menuAlign Alignment of the drop-down. Default is alignment with the start side of its parent.
17+
* 'end' aligns with the end side of its parent.
1618
*/
1719
$wrapperTag = $this->wrapperTag ?? 'div';
1820
$wrapperClass = 'dropdown'; // Bootstrap class
@@ -52,7 +54,13 @@
5254
)
5355
?>
5456

55-
<ul class="dropdown-menu">
57+
<?php
58+
$menuAttributes = $this->htmlAttributes(['class' => 'dropdown-menu']);
59+
if ('end' == ($this->menuAlign ?? null)) {
60+
$menuAttributes->add('class', 'dropdown-menu-end');
61+
}
62+
?>
63+
<ul<?=$menuAttributes?>>
5664
<?php foreach ($this->menuItems as $current): ?>
5765
<li class="dropdown__item">
5866
<a class="dropdown-item dropdown__link<?=($current['selected'] ?? false) ? ' active' : ''?>"

0 commit comments

Comments
 (0)