Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
MUI Menu options triggers handleClickOutside

So I have my custom Dialog component and useClickOutside hook

export function useClickOutside<T extends HTMLElement>(
ref: RefObject<T>,
callback: (event: MouseEvent) => void,
) {
const handleClick = useCallback(
(event: MouseEvent) => {
  if (!ref.current || ref.current.contains(event?.target as Node)) {
    return
  }
  callback(event)
},
[ref, callback],
)

useEffect(() => {
document.addEventListener('mousedown', handleClick)

return () => {
  return document.removeEventListener('mousedown', handleClick)
}
}, [handleClick, ref])
}

and inside of this dialog I use MUI Select and whenever I open options menu, it triggers my hook and dialog closes.

I've got to the point that options menu renders outside of dialog parent div and apply aria-hidden:"true" to the root div and dialog div both this is how it looks

So is there any way to render Options menu inside of a parent div or avoid useClickOutside trigger when I choose any option inside a menu?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!