patw0929 / react-smartbanner

Rewrite Smart App Banner in React.js.
https://patw0929.github.io/react-smartbanner/
MIT License
74 stars 56 forks source link

remove root element class names after unmounting SmartBanner component #42

Closed tnass closed 5 years ago

tnass commented 5 years ago

I've noticed that the class names on the HTML tag are not getting removed from the DOM once the SmartBanner gets unmounted. This can lead to undesired effects if other styles depend on those class names. In my case I wanted to push another banner (cookie policy) below the SmartBanner, so I've used the smartbanner-show class as a sibling class in the css code. As I only display the SmartBanner under certain conditions and not on all pages, there is the possibility for it to get unmounted from the DOM. If that happens without the user interacting with it, the class names need to get removed from DOM manually.

I've used element.classList.remove with one parameter and repeated it for all the possible class names to not break it in IE11. A unit test has been added, too. For whatever reason I also had to update the snapshot file.

outdooricon commented 5 years ago

We're really interested in this. @patw0929 is there any chance we could get this merged?

patw0929 commented 5 years ago

You're right, that styles should be removed. Thank you! Already merged and will be publish new version after a few other PRs merged.

outdooricon commented 5 years ago

fantastic, thanks @patw0929 !