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

504
Vistas
React Bootstrap- Overlay Tooltip rendering in wrong position initially

I am writing a react bootstrap app where a button appears at the end of an animation. When the button first appears, I want a tooltip to appear next to it. Once the user hovers over and off the button, the tooltip should go away and re-appear whenever the user hovers over the button again. I've gotten this to work as desired, but when I position the button where I want it to be (fixed to the bottom of the screen), the tooltip initially renders in the wrong position (where the button was before being positioned).

I have created two simple examples to demonstrate this behavior.

In the first example, the button is positioned at the top of the screen and the tooltip behaves as this desire:

function Testing(){
    const refLink = useRef(null);

    const [overlayOpen, setOverlayOpen]  = useState(true); // Initially open
    const [textDone, setTextDone] = useState(false);
    useEffect(() => {
        const timeoutId = setTimeout(() => {
            setTextDone(true)
        },1000)
        return () => clearTimeout(timeoutId)
    },[])
    return(
        <Container>
            <Row>
                {textDone ?
                    <>
                    <Button ref={refLink} onMouseOver={() => setOverlayOpen(true)}
                            onMouseOut={() => setOverlayOpen(false)}
                    >
                        <FaComment/>
                    </Button>
                    <Overlay target={refLink.current} show={overlayOpen}
                             onHide={() => setOverlayOpen(false)} rootClose placement={"bottom"}>
                        <Tooltip>
                            Submit a personal response!
                        </Tooltip>
                    </Overlay>
                    </>
                    : ''
                }
            </Row>
        </Container>
   )
}

export default Testing

The textDone state is set to true once the "animation" finishes. To simplify the example, I omitted the animation itself and recreated the delay with setTimeout.

The second example is identical except for the following .css class added to the Row element in which the button, overlay, and tooltip are nested inside of.

.fixed-button{
    position:fixed;
    right: 20px;
    bottom: 20px;
}

With this addition, the button ends up where I want it, but the tooltip first appears at the top of the screen. Once I hover over the button, the tooltip moves to the correct position.

Here are some gifs of the two examples.

Example 1 (tooltip behaving as intended but button not positioned in right spot)

Example 2 (button positioned where I want it but tooltip initially showing up in wrong spot)

My question is: how can I get the tooltip to initially appear in the correct position?

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