Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DropdownMenu positioning issue #2812

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/kind-countries-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@commercetools-uikit/dropdown-menu': patch
'@commercetools-uikit/data-table-manager': patch
---

We fixed an issue with the `DropdownMenu` component when using these values:

* `menuPosition`: right
* `menuHorizontalConstraint`: auto

In that situation, the width and positioning of the floating menu was not correctly calculated.
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ function DropdownBaseMenu(props: TDropdownBaseMenuProps) {
if (props.isOpen && props.triggerElementRef.current && menuRef.current) {
const triggerElementCoordinates =
props.triggerElementRef.current.getBoundingClientRect();
const menuElementCoordinates = menuRef.current.getBoundingClientRect();

menuRef.current.style.top = `${
triggerElementCoordinates.top + triggerElementCoordinates.height
}px`;
menuRef.current.style.left =
props.menuPosition === 'left'
? `${triggerElementCoordinates.left}px`
: `${
triggerElementCoordinates.left +
triggerElementCoordinates.width -
menuElementCoordinates.width
}px`;
if (props.menuPosition === 'left') {
menuRef.current.style.left = `${triggerElementCoordinates.left}px`;
menuRef.current.style.removeProperty('right');
} else {
menuRef.current.style.right = `${
window.innerWidth - triggerElementCoordinates.right
}px`;
menuRef.current.style.removeProperty('left');
}
menuRef.current.style.maxHeight = props.menuMaxHeight
? `${props.menuMaxHeight}px`
: `calc(${
Expand Down