Skip to content

Commit

Permalink
fix(protocol-designer): fix dropdownmenu expands upwards (#16713)
Browse files Browse the repository at this point in the history
* fix(protocol-designer): fix dropdownmenu expands upwards (#16713)
  • Loading branch information
koji authored Nov 7, 2024
1 parent 7e59b53 commit 825c23c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface ListItemCustomizeProps {
label?: string
dropdown?: DropdownMenuProps
tag?: TagProps
/** temporary prop for dropdown menu */
forceDirection?: boolean
}

export function ListItemCustomize(props: ListItemCustomizeProps): JSX.Element {
Expand All @@ -29,6 +31,7 @@ export function ListItemCustomize(props: ListItemCustomizeProps): JSX.Element {
linkText,
dropdown,
tag,
forceDirection = false,
} = props
return (
<Flex width="100%" alignItems={ALIGN_CENTER} padding={SPACING.spacing12}>
Expand All @@ -49,7 +52,9 @@ export function ListItemCustomize(props: ListItemCustomizeProps): JSX.Element {
{label}
</StyledText>
) : null}
{dropdown != null ? <DropdownMenu {...dropdown} /> : null}
{dropdown != null ? (
<DropdownMenu {...dropdown} forceDirection={forceDirection} />
) : null}
{tag != null ? <Tag {...tag} /> : null}
</Flex>
{onClick != null && linkText != null ? (
Expand Down
4 changes: 4 additions & 0 deletions components/src/molecules/DropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export interface DropdownMenuProps {
onBlur?: React.FocusEventHandler<HTMLButtonElement>
/** optional disabled */
disabled?: boolean
/** force direction for pd after release this will be fixed and remove */
forceDirection?: boolean
}

// TODO: (smb: 4/15/22) refactor this to use html select for accessibility
Expand All @@ -88,6 +90,7 @@ export function DropdownMenu(props: DropdownMenuProps): JSX.Element {
disabled = false,
onFocus,
onBlur,
forceDirection = false,
} = props
const [targetProps, tooltipProps] = useHoverTooltip()
const [showDropdownMenu, setShowDropdownMenu] = React.useState<boolean>(false)
Expand All @@ -105,6 +108,7 @@ export function DropdownMenu(props: DropdownMenuProps): JSX.Element {
})

React.useEffect(() => {
if (forceDirection) return
const handlePositionCalculation = (): void => {
const dropdownRect = dropDownMenuWrapperRef.current?.getBoundingClientRect()
if (dropdownRect != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export function SelectFixtures(props: WizardTileProps): JSX.Element | null {
return (
<ListItem type="noActive" key={ae}>
<ListItemCustomize
forceDirection
linkText={t('remove')}
onClick={() => {
setValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export function SelectModules(props: WizardTileProps): JSX.Element | null {
return (
<ListItem type="noActive" key={`${module.model}`}>
<ListItemCustomize
forceDirection
dropdown={
MOAM_MODULE_TYPES.includes(module.type) &&
robotType === FLEX_ROBOT_TYPE
Expand Down

0 comments on commit 825c23c

Please sign in to comment.