Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

274
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda