question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resize Stops Working after Browser Back

See original GitHub issue

First off, I wanna say thanks for this awesome module! I’m thoroughly happy with it. Now, the issue I’m experiencing might be specific to my project because I’m using react-router and turbolinks. After navigating through pages via browser back/forward, resizing no longer works.

I did some debugging and found out the cause. Sometimes, the browser creates a new document.body, but hiddenTextarea keeps pointing at old body (and hence causing memory leak. Not sure where this behavior is from, BFCache might be the culprit here).

The quick fix I found is to change the following statement in calculateNodeHeight.js

  // Before change
  if (hiddenTextarea.parentNode === null) {
    document.body.appendChild(hiddenTextarea);
  }
  // After change
  if (!document.body.contains(hiddenTextarea)) { /.../ }

This way, you can always check for the latest body to see whether or not hiddenTextarea exists in the current body instance. There might be a better way, but this is a one-liner fix.

If you’d like, I can quickly make the change, add some tests, and submit a PR. Let me know what you think 😃

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mendelkcommented, Jul 28, 2020

Sorry for the spam. @yucho Beat you to it 😃

0reactions
mendelkcommented, Aug 13, 2020

@Andarist Did you get a chance to look at #292 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elements dont position back to normal after resizing browser ...
When i resize the window to small size like 900px wide, the inputs and selects position like i want them to, but when...
Read more >
CSS - Responsive site – Problem with resizing the browser
Hi, I'm making my first full responsive site and I have run into an issue. The site seems to be working as intended...
Read more >
ScrollTrigger.refresh() not working as expected on resize - GSAP
It's my understanding that ScrollTrigger/Scrub animations should refresh when the browser resizes but it's not working right for me.
Read more >
Manually Trigger Browser Resize - Google Groups
This code does the job fine when the browser resizes. However now I would like manually trigger the browser resize event to force...
Read more >
Re-render a React Component on Window Resize | Pluralsight
addEventListener('resize', handleResize) 10 }) 11 return <div>w00t! ... But the above code will not yet re-render anything when the resize ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found