Skip to content

Commit c6250e0

Browse files
committed
Feat: IGL-115 - Added dropdownClassName & dropdownOffset
1 parent cda8fc0 commit c6250e0

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

.changeset/loud-singers-enjoy.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@igloo-ui/action-menu": minor
3+
"@igloo-ui/dropdown": minor
4+
---
5+
6+
Added dropdownOffset to Actionmenu and Dropdown components. Also added dropdownClassName to ActionMenu.

packages/ActionMenu/src/ActionMenu.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ export interface ActionMenuProps extends React.ComponentProps<"div"> {
3434
/** Whether or not the menu should use ReactPortal
3535
* to append to the body */
3636
disablePortal?: boolean;
37+
/** Add a specific class to the dropdown */
38+
dropdownClassName?: string;
39+
/** Offset of the dropdown */
40+
dropdownOffset?: number;
3741
/** Whether or not the action menu should be open by default */
3842
isOpen?: boolean;
3943
/** Callback when the action menu is closed and animations are done */
@@ -57,6 +61,8 @@ const ActionMenu: React.FunctionComponent<ActionMenuProps> = ({
5761
className,
5862
dataTest,
5963
disablePortal = false,
64+
dropdownClassName,
65+
dropdownOffset,
6066
isOpen = false,
6167
onAfterMenuClose,
6268
onMenuClose,
@@ -244,7 +250,8 @@ const ActionMenu: React.FunctionComponent<ActionMenuProps> = ({
244250
/>
245251
}
246252
isOpen={showMenu}
247-
className="ids-action-menu__dropdown"
253+
className={cx("ids-action-menu__dropdown", dropdownClassName)}
254+
dropdownOffset={dropdownOffset}
248255
position={position}
249256
onClose={() => toggleMenu(false)}
250257
onAfterClose={onAfterMenuClose}

packages/Dropdown/src/Dropdown.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export interface DropdownProps
7070
/** The threshold in pixels from the bottom of the dropdown
7171
* to trigger the onScrollEnd callback */
7272
scrollEndThreshold?: number;
73+
/** The offset of the dropdown from the reference */
74+
dropdownOffset?: number;
7375
}
7476

7577
const Dropdown: React.FunctionComponent<DropdownProps> = React.forwardRef(
@@ -93,6 +95,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = React.forwardRef(
9395
footer,
9496
onScrollEnd,
9597
scrollEndThreshold = 30,
98+
dropdownOffset = 4,
9699
...rest
97100
}: DropdownProps,
98101
ref: React.ForwardedRef<HTMLDivElement>
@@ -147,7 +150,7 @@ const Dropdown: React.FunctionComponent<DropdownProps> = React.forwardRef(
147150
return cleanup;
148151
},
149152
middleware: [
150-
offset(1),
153+
offset(dropdownOffset),
151154
flip({ padding: 10 }),
152155
fuiSize({
153156
apply({ rects, elements, availableHeight }) {

packages/Dropdown/src/__mocks__/Dropdown.mock.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ export interface DropdownProps
5454
/** The threshold in pixels from the bottom of the dropdown
5555
* to trigger the onScrollEnd callback */
5656
scrollEndThreshold?: number;
57+
/** The offset of the dropdown from the reference */
58+
dropdownOffset?: number;
5759
}
5860

5961
const MockDropdown: React.FunctionComponent<DropdownProps> = ({
@@ -75,6 +77,7 @@ const MockDropdown: React.FunctionComponent<DropdownProps> = ({
7577
footer,
7678
onScrollEnd,
7779
scrollEndThreshold = 30,
80+
dropdownOffset = 4,
7881
...rest
7982
}: DropdownProps) => {
8083
const { x, y, refs } = {

0 commit comments

Comments
 (0)