w3c / w3c-website

W3C Website feedback and bug reports
https://www.w3.org/
240 stars 80 forks source link

CTRL+click in group list also opens page in the current tab #500

Closed pchampin closed 1 year ago

pchampin commented 1 year ago

Describe the issue Visiting https://www.w3.org/groups/wg/ (but the same occurs on the page for IGs or CGs), when I CTRL+click on the link for a given group, it opens in a new tab BUT the current tab also navigates to group's page.

To reproduce see above

Expected behavior The origin tab should stay on the group list.

Screenshots N/A

Additional context I understand that the intent is to make clicks on the card behave like clicks on the link. I experimented with an alternative way of achieving that, while preserving the "modifiers" on the click. The event handler would have to look like that:

function(ev) {
    var someTextSelected = window.getSelection().toString();
    if (ev.redispatched || someTextSelected) {
        return; // ignore
    }
    var ev2 = new MouseEvent("click", ev);
    ev2.redispatched = true; 
    mainLink.dispatchEvent(ev2);
}
deniak commented 1 year ago

Thanks for the report and the suggested fix. I made a small variation to your suggestion to avoid getting the link opened in 2 new tabs. See https://github.com/w3c/w3c-website-templates-bundle/pull/121.