adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.15k stars 1.06k forks source link

Tree crashes when trying to set `expandedKeys = "all"` #6568

Open larrifax opened 2 weeks ago

larrifax commented 2 weeks ago

Provide a general summary of the issue here

I'm trying to use the new Tree component from react-aria-components, but it crashes when attempting to set expandedKeys prop to "all" (which should be a valid value according to the types).

See reproduction below

๐Ÿค” Expected Behavior?

Tree should successfully expand all possible keys

๐Ÿ˜ฏ Current Behavior

Tree crashes with error:

expandedKeys.has is not a function
visitNode
https://lz5k72.csb.app/node_modules/react-aria-components/dist/Tree.main.js:418:71
visitNode
https://lz5k72.csb.app/node_modules/react-aria-components/dist/Tree.main.js:421:60
$c6576bb58bfa084b$var$flattenTree
https://lz5k72.csb.app/node_modules/react-aria-components/dist/Tree.main.js:423:33
new $c6576bb58bfa084b$var$TreeCollection
https://lz5k72.csb.app/node_modules/react-aria-components/dist/Tree.main.js:103:64

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

https://codesandbox.io/p/sandbox/priceless-rgb-lz5k72

  1. Click the Expand explicit button. Expansion is performed as expected
  2. Click the Expand all button. Tree crashes and error message is displayed

Version

1.2.1

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Windows

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

larrifax commented 2 weeks ago

Looks like I've might have jumped the gun a bit here wrt. this being a bug vs a feature request (?).

The types doesn't really allow "all" in its type, but Typescript doesn't complain either when you supply it. ๐Ÿคท Also, the convertExpanded()-function that's used on the incoming expandedKeys-prop seems to support "all" as a value, so it tricked me into believing that it was intended to work.