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

120
Vistas
React Portal Not Working With A Tooltip Component

I'm trying to use react-portal with my tooltip component. There are no errors, however it does not appear to be working:

  1. The tooltip is still partially hidden by its parent container with overflow:hidden
  2. I do not see it added to a new div outside of #root.
import { Portal } from 'react-portal';

return (
    <>
      <Wrapper
        onMouseEnter={showTip}
        onMouseLeave={hideTip}
        ref={triggerRef}
      >
        {children}
      </Wrapper>

      {render && (
        <Portal node={triggerRef.current}>
          <Content
            placement={placement}
            fade={active}
          >
            {content}
          </Content>
        </Portal>
      )}
    </>
  );

Here's the Codesandbox for full code.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think there is nothing wrong with react portal , the problem is your style , I made a little change in your portal.js file:

  if (typeof window === "object") {
    if (target) {
      root = document.getElementById("root");
    }
    el = document.createElement("div");
    el.setAttribute('style', 'position:relative'); // this line
    el.id = "portal-root";
  } 

because your tooltip displayed right on your text and onMouseLeave immediately called and tooltip hides again so in the styled component and in the top case when I changed bottom style:

  ${({ placement }) =>
    placement === "top" &&
    css`
      bottom: calc(100% + 50px); // this line
      &::before {
        top: calc(100% - 10px);
      }
    `}

and its works: enter image description here

about 4 years ago · Juan Pablo Isaza Denunciar
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