Skip to content

Feat - itemAnchorClick#577

Open
lofcz wants to merge 1 commit into
haltu:masterfrom
lofcz:feat-anchor-click
Open

Feat - itemAnchorClick#577
lofcz wants to merge 1 commit into
haltu:masterfrom
lofcz:feat-anchor-click

Conversation

@lofcz

@lofcz lofcz commented Jun 23, 2025

Copy link
Copy Markdown

Currently, Muuri always opens <a> hrefs when clicked - we needed a mechanism to do this conditionally. Think Jira-like kanban board where items are represented by <a> elements, and the elements contain a checkbox which prevents opening the href:

image

To support this, a new option itemAnchorClick is introduced. If set, this handler enables preventing navigation. We use it like:

itemAnchorClick: function(item, event) {

    // if we clicked on the checkbox, stop
    if (event.target.closest('.kanbanCardCheckbox')) {
        event.preventDefault();
        return false;
    }
    
    let id = item.getElement().getAttribute("data-el-id");
    
    // clicked on the item, navigate (Blazor)
    if (id) {
        pars.net["invokeMethodAsync"]("JsAppNavigation", id);
    }
    
    return false; // return true would result in calling "openAnchorHref" as before this PR
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant