vrimar / construct-ui

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

Tooltip on button that becomes disabled does not disappear #12

Open angrytongan opened 4 years ago

angrytongan commented 4 years ago

Disabling a button with a tooltip shown does not remove the tooltip. Tested with Chrome on Mac OS X.

const {
    Button,
    FocusManager,
    Tooltip,

} = CUI;
FocusManager.showFocusOnlyOnTab();

const TooltipDisablingButton = () => {
    let buttonDisabled = false;

    return {
        view: () => {
            return m(Tooltip, {
                content: 'Tooltip remains after button disabled',
                trigger: m(Button, {
                    label: 'Click to disable',
                    disabled: buttonDisabled,
                    onclick: () => {
                        buttonDisabled = true;
                    },
                })
            });
        },
    };
};

document.addEventListener('DOMContentLoaded', () => {
    m.route(document.body, '/', {
        '/': TooltipDisablingButton
    });
});
vrimar commented 4 years ago

I'm going to rework the Tooltip logic, seems like it has quite a few issues I didn't consider.