Skip to content

Commit 7e50be4

Browse files
author
jmainguytalend
committed
Fix Dropdown placement & style
1 parent e4c954a commit 7e50be4

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

packages/design-system/src/components/Dropdown/Dropdown.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { cloneElement, MouseEvent, ReactElement, useState } from 'react';
2+
23
import {
34
useDismiss,
45
useInteractions,
@@ -7,14 +8,15 @@ import {
78
flip,
89
shift,
910
} from '@floating-ui/react';
10-
import MenuButton from './Primitive/MenuButton';
11+
12+
import { DataAttributes, DeprecatedIconNames } from '../../types';
13+
import Clickable, { ClickableProps } from '../Clickable';
14+
import { LinkableType } from '../Linkable';
15+
import DropdownDivider from './Primitive/DropdownDivider';
1116
import DropdownLink from './Primitive/DropdownLink';
1217
import DropdownShell from './Primitive/DropdownShell';
1318
import DropdownTitle from './Primitive/DropdownTitle';
14-
import DropdownDivider from './Primitive/DropdownDivider';
15-
import Clickable, { ClickableProps } from '../Clickable';
16-
import { LinkableType } from '../Linkable';
17-
import { DataAttributes, DeprecatedIconNames } from '../../types';
19+
import MenuButton from './Primitive/MenuButton';
1820

1921
type DropdownButtonType = Omit<ClickableProps, 'children'> & {
2022
label: string;
@@ -59,9 +61,10 @@ const Dropdown = ({
5961
const [isOpen, setIsOpen] = useState(false);
6062

6163
const floating = useFloating({
64+
placement: 'bottom-start',
6265
open: isOpen,
6366
onOpenChange: setIsOpen,
64-
middleware: [/*offset(10),*/ flip(), shift()],
67+
middleware: [flip(), shift()],
6568
whileElementsMounted: autoUpdate,
6669
});
6770
const dismiss = useDismiss(floating.context, {
@@ -106,7 +109,6 @@ const Dropdown = ({
106109
onClick={(event: MouseEvent<HTMLButtonElement> | KeyboardEvent) => {
107110
entry.onClick(event);
108111
setIsOpen(false);
109-
console.log('closed but sent');
110112
}}
111113
key={id}
112114
tabIndex={0}

packages/design-system/src/components/Dropdown/Primitive/MenuButton.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { forwardRef, Ref } from 'react';
2+
23
// eslint-disable-next-line @talend/import-depth
34
import { IconNameWithSize } from '@talend/icons/dist/typeUtils';
45

@@ -15,17 +16,19 @@ export type MenuButtonType = ClickableProps & /*MenuItemProps &*/ {
1516
const MenuButton = forwardRef(
1617
({ children, icon, ...props }: MenuButtonType, ref: Ref<HTMLButtonElement>) => {
1718
return (
18-
<Clickable {...props} className={styles.dropdownEntry} ref={ref}>
19-
{icon && (
20-
<span className={styles.buttonIcon}>
21-
{getIconWithDeprecatedSupport({
22-
iconSrc: icon,
23-
size: 'M',
24-
['data-test']: 'button.icon.before',
25-
})}
26-
</span>
27-
)}
28-
<span className={styles.buttonContent}>{children}</span>
19+
<Clickable {...props} ref={ref}>
20+
<div className={styles.dropdownEntry}>
21+
{icon && (
22+
<span className={styles.buttonIcon}>
23+
{getIconWithDeprecatedSupport({
24+
iconSrc: icon,
25+
size: 'M',
26+
['data-test']: 'button.icon.before',
27+
})}
28+
</span>
29+
)}
30+
<span className={styles.buttonContent}>{children}</span>
31+
</div>
2932
</Clickable>
3033
);
3134
},

0 commit comments

Comments
 (0)