Skip to content

Commit

Permalink
Merge pull request #1933 from roberdm49/TP-1686-avoid-dropdown-blink
Browse files Browse the repository at this point in the history
TP-1686: Ref moved to the parent element
  • Loading branch information
aguescribano87 authored Aug 19, 2024
2 parents 794a9f8 + bcfa7cd commit b60cc57
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/dropdown/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const Dropdown = ({ children, ...props }) => {

useOnClickOutside(ref, () => toggle(false))

const value = React.useMemo(() => ({ open, toggle, ref }), [open])
const value = React.useMemo(() => ({ open, toggle }), [open])

return (
<DropdownContext.Provider value={value}>
<Box {...props} __css={{ position: 'relative', height: '200px' }}>
<Box ref={ref} {...props} __css={{ position: 'relative', height: '200px' }}>
{children}
</Box>
</DropdownContext.Provider>
Expand Down Expand Up @@ -93,12 +93,11 @@ const DropdownButton = ({ icon, text, variant = 'dropdown', disabled = false, fi
}

const DropdownList = ({ children, width = '236px', height = '150px', clickClose = false, ...props }) => {
const { open, ref, toggle } = useDropdownContext()
const { open, toggle } = useDropdownContext()
return (
open && (
<List
onClick={clickClose ? toggle : () => {}}
ref={ref}
{...props}
sx={{
display: 'flex',
Expand Down

0 comments on commit b60cc57

Please sign in to comment.