Skip to content

[Bug] ListItem: the row's onClick runs for clicks in a caller's portal and on role-based controls #8977

Closed

Description

@duytbp

Description

A clickable ListItem (Item with onClick and no role) runs its onClick for clicks that belong to something else:

  • a click inside content the caller portals out of the row with its own createPortal: React bubbles the click through the portal, though the target is not in the row's DOM;
  • a click on a control with an ARIA role rather than a native element, such as role="tab" or role="switch".

handleContainerClick skips only targets inside button, a, input, select, textarea and does not check that the target is inside the row (Item/Item.tsx:839-846). The shared hasInteractiveAncestor in hooks/useClickableContainer.ts, which Item's delegate rows and TreeListItem already use, covers role-based controls.

Expected: the row's onClick runs only for a click whose target is inside the row's own DOM and not inside a nested control, native or role-based. #9393 makes this change.

Reproduction

import {createPortal} from 'react-dom';
import {List, ListItem} from '@astryxdesign/core';

export function Repro() {
  return (
    <List>
      <ListItem
        label="Invoice 42"
        onClick={() => console.log('open invoice')}
        endContent={
          <>
            <div role="tab" tabIndex={0} onClick={() => console.log('tab')}>
              Details
            </div>
            {createPortal(
              <div onClick={() => console.log('portal')}>Outside</div>,
              document.body,
            )}
          </>
        }
      />
    </List>
  );
}
  1. Click "Details": tab and open invoice are logged.
  2. Click "Outside" (rendered in document.body): portal and open invoice are logged.

(A MoreMenu in endContent, the first repro here, no longer shows this on main.)

Astryx Version

@astryxdesign/[email protected], unchanged on main (4e39f9c)

Environment

Verified by reading the source on main (the role-based and portal cases are the ones #9393 tests in jsdom). Any browser.

Activity

  1. added a commit that references this issue on Nov 2, 2026
    0bdd8d1
  2. added
    bug
    component
    on Nov 2, 2026
  3. added 2 commits that reference this issue on Nov 4, 2026
    a0c218a
    a6ae3b8
  4. changed the title [-][Bug] ListItem: the row's onClick runs for clicks in its portals and on role-based controls[/-] [+][Bug] ListItem: the row's onClick runs for clicks in a caller's portal and on role-based controls[/+] on Nov 13, 2026
  5. added
    lane:1
    on Nov 16, 2026
  6. cixzhang commented on Nov 19, 2026

    @cixzhang
    Contributor

    (Posted by Cindy's agent.) Thanks @duytbp for the report. A fix is proposed in #9393, but which clicks should run a row's onClick (portals and role-based controls) isn't settled in the Item contract yet. It's with the owner for a decision. We'll update here and review #9393 against it.

  7. cixzhang commented on Nov 21, 2026

    @cixzhang
    Contributor

    (Posted by Cindy's agent.) Fixed in #9393 by @HelloOjasMutreja, now merged: a ListItem's onClick no longer runs for clicks in a caller's portal or on role-based controls in the row. It ships in the next release. Thanks again for the clear report, @duytbp!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugcomponentlane:1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions