Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!