Skip to content

Commit

Permalink
Extract from 344e288c8c084756f11a0a903f2b9b970119ab71
Browse files Browse the repository at this point in the history
  • Loading branch information
akeneo committed May 27, 2024
1 parent 34b2a78 commit 8a0eb6e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
6 changes: 5 additions & 1 deletion lib/components/Dropdown/Overlay/Overlay.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/components/Dropdown/Overlay/Overlay.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "akeneo-design-system",
"version": "0.1.241",
"version": "0.1.242",
"description": "Akeneo design system",
"main": "lib/index.js",
"scripts": {
Expand Down
13 changes: 9 additions & 4 deletions src/components/Dropdown/Overlay/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Container = styled.div<
fixedWidth: number | null;
} & AkeneoThemedProps
>`
${CommonStyle}
${CommonStyle};
background: ${getColor('white')};
box-shadow: 0 0 4px 0 rgba(0, 0, 0, 0.3);
padding: 10px 0;
Expand All @@ -45,8 +45,7 @@ const Container = styled.div<
z-index: 1901;
top: ${({top}) => top}px;
left: ${({left}) => left}px;
${getWidthProperties}
${getWidthProperties};
`;

type OverlayProps = Override<
Expand Down Expand Up @@ -84,7 +83,7 @@ type OverlayProps = Override<
}
>;

const Backdrop = styled.div<{isOpen: boolean} & AkeneoThemedProps>`
const Backdrop = styled.div`
position: fixed;
top: 0;
left: 0;
Expand Down Expand Up @@ -121,6 +120,12 @@ const getOverlayPosition = (
top = 'up' === verticalPosition ? parentRect.top - elementRect.height : parentRect.bottom + 1;
}

// Adjust the vertical position to top if the dropdown list height exceeds the screen
const spaceBelow = window.innerHeight - parentRect.bottom;
const exceedsScreen = spaceBelow < elementRect.height && parentRect.top > elementRect.height;
top = exceedsScreen ? parentRect.bottom - elementRect.height + BORDER_SHADOW_OFFSET : top;
top = exceedsScreen && dropdownOpenerVisible ? parentRect.top - elementRect.height : top;

const left = 'left' === horizontalPosition ? parentRect.right - elementRect.width : parentRect.left;

return [top, left];
Expand Down

0 comments on commit 8a0eb6e

Please sign in to comment.