vrimar / construct-ui

A Mithril.js UI library
https://vrimar.github.io/construct-ui
MIT License
287 stars 23 forks source link

Toast included in view() does a redraw when it's removed from DOM #22

Closed angrytongan closed 1 year ago

angrytongan commented 4 years ago

Including a toaster in view() causes a redraw when it's removed from the DOM. Note in the code sample below I don't actually use the Toaster.

I'm pretty sure this isn't a bug, but was something that was unexpected. I've had a look at Toaster.js and Overlay and it all looks fine. No action necessary.

const {
    Toaster,
} = CUI;

const toaster = new Toaster();

const ToasterMultipleViewsSister = {
    view: () => {
        console.log('ToasterMultipleViewsSister.view');
        return [
            m(m.route.Link, { href: '/' }, 'Default'),
        ];
    },
};

const ToasterMultipleViews = {
    view: () => {
        console.log('ToasterMultipleViews.view');
        return [
            m(toaster),
            m(m.route.Link, { href: '/sister' }, 'Sister'),
        ]
    },
};

document.addEventListener('DOMContentLoaded', () => {
    m.route(document.body, '/', {
        '/':        ToasterMultipleViews,
        '/sister':  ToasterMultipleViewsSister,
    });
});