function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Andee Weir 20Andee Weir 20 

SLDS - How to create a SLDS button menu with correctly floating menu

Hi,

I've been tasked with creating a custom version of the Opportunity Team component that users currently see in the side panel.  Most of my development is fine but I am struggling to correctly position the button menu that appears when the dropdown arrow is clicked.

Salesforce working version :-
Salesforce standard button menuMy version :-
User-added image
As you can see on my version the menu items appear beneath & to the right of the dropdown (which means half the text is missing as the dropdown appears on the righthand side of the page) whereas the Salesforce version appears to the left & can also appear above the dropdown if there is not enough room on the browser beneath the dropdown.

Cutdown version of the aura component which demonstrates the problem when added to the righthand sidepanel of an opportunity page:-
<aura:component implements="force:hasRecordId,flexipage:availableForAllPageTypes" access="global">
	<div class="container forceRelatedListSingleContainer" data-aura-class="forceRelatedListSingleContainer">
        <article class="slds-card slds-card_boundary headerBottomBorder forceRelatedListCardDesktop" data-aura-class="forceRelatedListCardDesktop">
            <div class="slds-grid slds-page-header forceRelatedListCardHeader" data-aura-class="forceRelatedListCardHeader">
                <header class="slds-media slds-media--center slds-has-flexi-truncate" >
                    <div class="slds-media__figure stencil slds-avatar slds-avatar_small" aria-hidden="true">
                        <div class="extraSmall forceEntityIcon" style="background-color: #FCB95B" data-aura-class="forceEntityIcon">
                            <span class="uiImage" data-aura-class="uiImage">
                                <img src="/img/icon/t4v35/standard/team_member_120.png" class="icon " alt="Opportunity Team" title="Opportunity Team"/>
                            </span>
                        </div>
                    </div>
                    <div class="slds-media__body">
                        <h2 class="slds-card__header-title">
                            <a class="slds-card__header-link baseCard__header-title-container">
                                <span class="slds-truncate slds-m-right--xx-small" title="Opportunity Team">
                                    Opportunity Team
                                </span>
                            </a>
                        </h2>
                    </div>
                    
                    <div class="slds-p-around_medium container lgc-bg">
                        <lightning:buttonMenu alternativeText="Show menu" variant="border-filled">
                            <lightning:menuItem value="MenuItemOne" label="Menu Item One" />
                            <lightning:menuItem value="MenuItemTwo" label="Menu Item Two" />
                            <lightning:menuItem value="MenuItemThree" label="Menu Item Three" />
                            <lightning:menuItem value="MenuItemFour" label="Menu Item Four" />
                        </lightning:buttonMenu>
                    </div>
                    
                </header>
            </div>
        </article>
    </div>
</aura:component>
Any thoughts gratefully received.
 
Best Answer chosen by Andee Weir 20
Marcos LasoMarcos Laso
As stated on documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning:buttonMenu/specification) you can use "menuAlignment" public property with "right" value to align the menu in your desired position

All Answers

Marcos LasoMarcos Laso
As stated on documentation (https://developer.salesforce.com/docs/component-library/bundle/lightning:buttonMenu/specification) you can use "menuAlignment" public property with "right" value to align the menu in your desired position
This was selected as the best answer
Andee Weir 20Andee Weir 20
That's brilliant.  Thanks Marcos.  I was stupidly looking at the docs for the menuItem.  There is als oan 'auto' option which worked for me