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

166
Visualizações
Check whether there is a modal in front of my content or not?

I'm rendering some react content in a page via a plug-in so I have no control over the parent page that uses my content. The thing is that sometimes I use componentDidMount lifecycle to scroll to a specific element in my page.

There are cases where the parent page is using modals for consent (RGPD ones) when a page is loading, so my content is correctly loading and my componentDidMount and my scrolling method are running. Except that the page that is rendering this modal is blocking the scroll. Even when the modal is closed, my function already ran so it does not scroll.

I thought about listening for some changes with MutationObserver but it will not make it consistent as there is multiple "parents" that can render my content so as many different MutationObservers to set.

I also thought about maybe another lifecycle method that could detect if my content is blocked of partially rendered or something.

I simply have no idea about how to approach this issue.

Here is some code :

componentDidMount = () => {
        if (typeof window !== "undefined") {
            const pageAnchor = window.location.hash.slice(1);
            const argumentRegex = /argument_\d+/;
            const argumentAnchor = pageAnchor.match(argumentRegex);
            if (argumentAnchor) {
                const argumentId = this.getId();
                if (argumentAnchor[0] === argumentId) {
                    scroller.scrollTo(argumentId, { duration: 1000, smooth: false, offset: -80 });
                }
            }
        }
    };

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