Skip to content

Commit

Permalink
fix: header dropdown misplacement on icon click (#1297)
Browse files Browse the repository at this point in the history
Resolves
#1247.

Dropdown misplacement would occur when the `Icon` itself was clicked,
not the text, resulting in a bad anchor element.
  • Loading branch information
daniel-ji authored Nov 4, 2024
1 parent aa2b28f commit 8ecb914
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/packages/data-portal/app/components/MenuDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Icon, Menu } from '@czi-sds/components'
import { ReactNode, useState } from 'react'
import { ReactNode, useRef, useState } from 'react'

import { cns } from 'app/utils/cns'

Expand All @@ -13,15 +13,17 @@ export function MenuDropdown({
title: ReactNode
}) {
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)
const menuRef = useRef<HTMLDivElement>(null)

return (
<div className={className}>
<button
className="!p-0 flex items-center gap-2 group"
onClick={(event) => setAnchorEl(event.target as HTMLElement | null)}
onClick={() => setAnchorEl(menuRef.current)}
type="button"
>
<span
ref={menuRef}
className={cns(
'font-semibold',

Expand Down

0 comments on commit 8ecb914

Please sign in to comment.