Skip to content

fix: add DEFAULT_SLOT to TreeItem CheckboxContext so unslotted Checkboxes render#10274

Open
mvanhorn wants to merge 1 commit into
adobe:mainfrom
mvanhorn:fix/10204-fix-add-defaultslot-to-treeitem-checkbox
Open

fix: add DEFAULT_SLOT to TreeItem CheckboxContext so unslotted Checkboxes render#10274
mvanhorn wants to merge 1 commit into
adobe:mainfrom
mvanhorn:fix/10204-fix-add-defaultslot-to-treeitem-checkbox

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Closes #10204

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component). No documentation changes are needed for this internal slot fix.
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

TreeItem provided a CheckboxContext/CheckboxFieldContext whose slots only contained selection, unlike TableRow and GridListItem which also include [DEFAULT_SLOT]: {}. As a result, any Checkbox or CheckboxField without slot="selection" rendered as a React descendant of a TreeItem threw A slot prop is required. Valid slot names are "selection".

This adds [DEFAULT_SLOT]: {} to both slot maps in TreeItem, mirroring Table.tsx, so an unslotted checkbox renders normally while the existing slot="selection" behavior is unchanged.

To verify:

  1. Render a Tree with a TreeItem containing an unslotted <Checkbox> in its content. It now renders without throwing.
  2. A Checkbox slot="selection" inside a TreeItem still drives selection (no regression).

Tests:

yarn jest packages/react-aria-components/test/Tree.test.tsx

Result: 109 passed, 1 skipped. Added a new case asserting an unslotted Checkbox under a TreeItem renders without error.

🧢 Your Project:

Community contribution.

@snowystinger snowystinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TreeItem does not include DEFAULT_SLOT in CheckboxContext, causing Checkbox crash when rendered inside modals/portals

2 participants