Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

275
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda