vrimar / construct-ui

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

contentLeft and contentRight in ListItem don't register click event #15

Closed angrytongan closed 4 years ago

angrytongan commented 4 years ago

Clicking on content set with contentLeft and contentRight to a ListItem doesn't register the click. Anywhere else on the ListItem does.

const {
    List,
    ListItem,
} = CUI;

const ListLeftRightContentNoClickRegister = () => {
    const items = [
        'one',
        'two',
        'three',
        'four',
        'five',
    ];

    return {
        view: () => {
            return m(List, items.map((l) => m(ListItem, {
                label: l,
                contentLeft: 'left',
                contentRight: 'right',
                onclick: (e) => {
                    console.log(l, 'click');
                },
            })));
        },
    };
};

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

Hm, after a bit of thought - is this by design?

vrimar commented 4 years ago

Yeah that's intentional, I guess I could add a prop to enable/disable that functionality.

angrytongan commented 4 years ago

No worries. Use case is when an icon is used; expectation would be that clicking anywhere on the ListItem, including the icon, would register as a click.

vrimar commented 4 years ago

Added an allowOnContentClick attr in v0.2.3