Skip to content

RAC Tabs/useFocusWithin crashes with Failed to execute contains on Node on a Tabs-wrapped page with portal-based date/select controls #9890

@luisrudge

Description

@luisrudge

We are seeing a runtime crash in React Aria Components on a page wrapped in Tabs.

The page contains portal-based date/select controls. After interacting with those controls and then clicking a submit button, the app throws:

Uncaught TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.

We only see this when the page is wrapped in react-aria-components Tabs. The same schedule UI flow works on a page that is not wrapped in Tabs.

Expected Behavior?

No crash during focus/blur handling.

Current Behavior

The app crashes in useFocusWithin / nodeContains.

Stack:

Uncaught TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.
    at $d4ee10de306f2510$export$4282f70798064fe0 (react-aria-components.js?v=3fd722a5:230:84)
    at react-aria-components.js?v=3fd722a5:6471:8
    ...

Relevant bundled code:

function nodeContains(node, otherNode) {
  if (!shadowDOMEnabled) {
    return otherNode && node ? node.contains(otherNode) : false;
  }
  ...
}

and:

if (!nodeContains(e.currentTarget, getEventTarget(e))) return;

Context

We are not using Shadow DOM.

Observed behavior in our app:

  • page rendered inside react-aria-components Tabs → crash
  • same page content rendered outside Tabs → no crash

This suggests the issue is related to focus handling introduced by Tabs / useFocusWithin, but we do not yet have a minimal standalone reproduction.

Version

react-aria-components: 1.16.0
react-aria: 3.47.0
@react-aria/utils: 3.33.1

What browsers are you seeing the problem on?

Chrome

What operating system are you using?

macOS

Related upstream work

Possibly related:

Question

Is this a known scenario where the fallback non-shadow-DOM nodeContains path still needs to guard against non-Node values?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions