Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup settimeout throws error if dom element isn't on page. #1751

Closed
sdb1228 opened this issue Feb 16, 2020 · 1 comment · Fixed by #1752
Closed

cleanup settimeout throws error if dom element isn't on page. #1751

sdb1228 opened this issue Feb 16, 2020 · 1 comment · Fixed by #1752

Comments

@sdb1228
Copy link
Contributor

sdb1228 commented Feb 16, 2020

Expected behavior

When the rbd-announcement-1 div doesn't exist it doesn't try to remove it.

Actual behavior

rbd tries to remove a dom element that doesn't exist.

react-beautiful-dnd.esm.js:5466 Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
    at remove (http://localhost:3000/packs/js/application-12c072486af5cffa7be8.js:119874:26)

Steps to reproduce

I haven't gotten an isolated setup (sorry!) but if you use something like turbo links https://github.com/turbolinks/turbolinks with react-beautiful-dnd when you navigate to another page via a link the dom changes before reactdnds settimeout has time to run causing a dom error.

Suggested solution?

in the root component of your app you can do something like

    window.addEventListener('turbolinks:before-render', () => {
      const highestTimeoutId = setTimeout(';');
      for (let i = 0; i < highestTimeoutId; i++) {
        clearTimeout(i);
      }
    });

which will remove the settimeout for reactbeautifuldnd essentially squashing the error.

yes! in src/view/use-announcer/use-announcer.js:46 add a check before to see if the dom element exists before removing.

What version of React are you using?

16.12.0

What version of react-beautiful-dnd are you running?

12.2.0

What browser are you using?

chrome Version 79.0.3945.130 (Official Build) (64-bit)

@sdb1228
Copy link
Contributor Author

sdb1228 commented Feb 20, 2020

🎉 Just updated my package.json with the beta version and it silenced this error! Thanks @alexreardon

ulion added a commit to ulion/react-beautiful-dnd that referenced this issue Jul 26, 2021
ulion added a commit to ulion/react-beautiful-dnd that referenced this issue Jul 10, 2022
ulion added a commit to ulion/react-beautiful-dnd that referenced this issue Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant