Context Menu doesn't Open properly when too close to the edge of the screen.

Hi,

I have a context menu that I am opening with a button press.  It looks something like:


<SfContextMenu @ref="ContextMenuFromButton" Target="#OperationsViewContextMenu" TValue="MenuItem" Items="MenuItemsFromButton">

    <MenuEvents TValue="MenuItem" ItemSelected="ContextMenuItemClickedFromButton"></MenuEvents>

</SfContextMenu>

<span class="pr-2">

    <button id="OperationsViewContextMenu" class="btn btn-sm btn-secondary" type="button" @onclick="((args) => ContextMenuOpenFromButton(args, _operation))">

        <em class="fa fa-ellipsis-h"></em>

    </button>

</span>


And in my code behind I have:


public void ContextMenuOpenFromButton(MouseEventArgs e)

{

    ContextMenuOpenHandler(operation);

    ContextMenuFromButton.Open(e.ClientX, e.ClientY);

}


When my ClientY is too close to the bottom of the screen, the context menu does not open (see vid) and causes weird movement within the page.  I could get around this by doing some math before I call open and giving myselft extra space, but I feel like a solution should just work out of the box.  Thanks for the feedback.



Attachment: ContextMenuBroken_d80e5140.zip

2 Replies

ZW Zachary Witt September 26, 2022 07:08 PM UTC

Solved.. Needed to enableCollision like so when opening:


ContextMenuFromButton.Open(e.ClientX, e.ClientY , true);



YA YuvanShankar Arunagiri Syncfusion Team September 27, 2022 04:33 AM UTC

Hi Zachary,


Thanks for your update. Please let us know if you have any other queries.


Regards,

YuvanShankar A


Loader.
Up arrow icon