-
Notifications
You must be signed in to change notification settings - Fork 650
feat: add multiple selection support to Tree component #18086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add multiple selection support to Tree component #18086
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
| }) | ||
| .filter((item) => item !== null); | ||
|
|
||
| console.log(uuids, values); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x
| import type { Meta, StoryObj } from '@storybook/react'; | ||
|
|
||
| import Tree from '../components/common/Tree/Tree'; | ||
| // import Mantine8Provider from '../providers/Mantine8Provider'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x
d6a78ea to
dfa3cc3
Compare
| export const Primary: Story = { | ||
| args: { | ||
| value: 'fake11', | ||
| topLevelLabel: 'All spaces', | ||
| data: [ | ||
| { | ||
| uuid: 'fake0', | ||
| name: 'The most main space', | ||
| path: 'the_most_main_space', | ||
| }, | ||
| { | ||
| uuid: 'fake1', | ||
| name: 'Main space', | ||
| path: 'main_space', | ||
| }, | ||
| { | ||
| uuid: 'fake2', | ||
| name: 'Sub space', | ||
| path: 'main_space.sub', | ||
| }, | ||
| { | ||
| uuid: 'fake3', | ||
| name: 'Sub space 2', | ||
| path: 'main_space.sub2', | ||
| }, | ||
| { | ||
| uuid: 'fake4', | ||
| name: 'Sub space 3', | ||
| path: 'main_space.sub3', | ||
| }, | ||
| { | ||
| uuid: 'fake5', | ||
| name: 'Sub of sub space', | ||
| path: 'main_space.sub.sub_of_sub', | ||
| }, | ||
| { | ||
| uuid: 'fake6', | ||
| name: 'Sub of sub space 2', | ||
| path: 'main_space.sub.sub_of_sub2', | ||
| }, | ||
| { | ||
| uuid: 'fake7', | ||
| name: 'Sub of sub space 3', | ||
| path: 'main_space.sub.sub_of_sub3', | ||
| }, | ||
| { | ||
| uuid: 'fake10', | ||
| name: 'Sub of sub of sub space', | ||
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub', | ||
| }, | ||
| { | ||
| uuid: 'fake11', | ||
| name: 'Sub of sub of sub space 2', | ||
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub2', | ||
| }, | ||
| { | ||
| uuid: 'fake12', | ||
| name: 'Sub of sub of sub sub space', | ||
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub.sub_of_sub_of_sub_of_sub', | ||
| }, | ||
| { | ||
| uuid: 'fake13', | ||
| name: 'Sub of sub of sub sub space 2', | ||
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub.sub_of_sub_of_sub_of_sub2', | ||
| }, | ||
| { | ||
| uuid: 'fake14', | ||
| name: 'Kinda top level space', | ||
| path: 'kinda_top_level_space', | ||
| }, | ||
| { | ||
| uuid: 'fake15', | ||
| name: 'Kinda top level space 2', | ||
| path: 'kinda_top_level_space2', | ||
| }, | ||
| { | ||
| uuid: 'fake16', | ||
| name: 'Kinda top level space 3', | ||
| path: 'kinda_top_level_space3', | ||
| }, | ||
| ], | ||
| data, | ||
| onChange: (selectedUuid) => { | ||
| console.info('Selected item UUID:', selectedUuid); | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Primary story needs to include type: "single" to align with the updated Props type definition. Since it's using value and onChange, it should explicitly specify the selection type to maintain consistency with the component's new type system.
| export const Primary: Story = { | |
| args: { | |
| value: 'fake11', | |
| topLevelLabel: 'All spaces', | |
| data: [ | |
| { | |
| uuid: 'fake0', | |
| name: 'The most main space', | |
| path: 'the_most_main_space', | |
| }, | |
| { | |
| uuid: 'fake1', | |
| name: 'Main space', | |
| path: 'main_space', | |
| }, | |
| { | |
| uuid: 'fake2', | |
| name: 'Sub space', | |
| path: 'main_space.sub', | |
| }, | |
| { | |
| uuid: 'fake3', | |
| name: 'Sub space 2', | |
| path: 'main_space.sub2', | |
| }, | |
| { | |
| uuid: 'fake4', | |
| name: 'Sub space 3', | |
| path: 'main_space.sub3', | |
| }, | |
| { | |
| uuid: 'fake5', | |
| name: 'Sub of sub space', | |
| path: 'main_space.sub.sub_of_sub', | |
| }, | |
| { | |
| uuid: 'fake6', | |
| name: 'Sub of sub space 2', | |
| path: 'main_space.sub.sub_of_sub2', | |
| }, | |
| { | |
| uuid: 'fake7', | |
| name: 'Sub of sub space 3', | |
| path: 'main_space.sub.sub_of_sub3', | |
| }, | |
| { | |
| uuid: 'fake10', | |
| name: 'Sub of sub of sub space', | |
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub', | |
| }, | |
| { | |
| uuid: 'fake11', | |
| name: 'Sub of sub of sub space 2', | |
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub2', | |
| }, | |
| { | |
| uuid: 'fake12', | |
| name: 'Sub of sub of sub sub space', | |
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub.sub_of_sub_of_sub_of_sub', | |
| }, | |
| { | |
| uuid: 'fake13', | |
| name: 'Sub of sub of sub sub space 2', | |
| path: 'main_space.sub.sub_of_sub.sub_of_sub_of_sub.sub_of_sub_of_sub_of_sub2', | |
| }, | |
| { | |
| uuid: 'fake14', | |
| name: 'Kinda top level space', | |
| path: 'kinda_top_level_space', | |
| }, | |
| { | |
| uuid: 'fake15', | |
| name: 'Kinda top level space 2', | |
| path: 'kinda_top_level_space2', | |
| }, | |
| { | |
| uuid: 'fake16', | |
| name: 'Kinda top level space 3', | |
| path: 'kinda_top_level_space3', | |
| }, | |
| ], | |
| data, | |
| onChange: (selectedUuid) => { | |
| console.info('Selected item UUID:', selectedUuid); | |
| }, | |
| }, | |
| export const Primary: Story = { | |
| args: { | |
| value: 'fake11', | |
| topLevelLabel: 'All spaces', | |
| data, | |
| type: "single", | |
| onChange: (selectedUuid) => { | |
| console.info('Selected item UUID:', selectedUuid); | |
| }, | |
| }, |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
|
Your preview environment pr-18086 has been deployed with errors. |
|
Preview environment logs can be accessed at: https://console.cloud.google.com/logs/query;query=resource.labels.namespace_name%3D%22pr-18086%22;duration=PT30M?project=lightdash-previews |
|
You can ssh into the preview environment by running: |
| const values = useMemo( | ||
| () => | ||
| props.type === 'multiple' | ||
| ? props.values | ||
| : props.value | ||
| ? [props.value] | ||
| : [], | ||
| [ | ||
| props.type, | ||
| // @ts-expect-error - props.values and props.value are only defined if type is 'multiple' or 'single' | ||
| props.values, | ||
| // @ts-expect-error - props.values and props.value are only defined if type is 'multiple' or 'single' | ||
| props.value, | ||
| ], | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't think you need to memoize this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But can make the change after - testing now
joaoviana
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested
Merge activity
|
dfa3cc3 to
1522a0b
Compare
# [0.2166.0](0.2165.1...0.2166.0) (2025-11-13) ### Bug Fixes * wrap Storybook components with Mantine8Provider ([#18085](#18085)) ([18f67a9](18f67a9)) ### Features * add multiple selection support to Tree component ([#18086](#18086)) ([b78b7eb](b78b7eb)) * add space access control for AI agents ([#18061](#18061)) ([b9cb25a](b9cb25a)), closes [#18044](#18044) * improve oauth page styling ([#18075](#18075)) ([67b322e](67b322e))
|
🎉 This PR is included in version 0.2166.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
<!-- Thanks so much for your PR, your contribution is appreciated! ❤️ --> ### Description: Added multi-select functionality to the Tree component, allowing users to select multiple items in a tree structure. This enhancement includes: - Added a new `type` prop to specify whether the tree supports single or multiple selection - Implemented recursive selection/deselection of child nodes when a parent is selected in multi-select mode - Updated the SpaceSelector component to explicitly use single selection mode - Added a new story to demonstrate the multi-select functionality [CleanShot 2025-11-13 at 12.22.06.mp4 <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.com/user-attachments/thumbnails/4dde0a9f-34c1-4def-b7be-9da78261bd4d.mp4" />](https://app.graphite.com/user-attachments/video/4dde0a9f-34c1-4def-b7be-9da78261bd4d.mp4)
# [0.2166.0](lightdash/lightdash@0.2165.1...0.2166.0) (2025-11-13) ### Bug Fixes * wrap Storybook components with Mantine8Provider ([lightdash#18085](lightdash#18085)) ([18f67a9](lightdash@18f67a9)) ### Features * add multiple selection support to Tree component ([lightdash#18086](lightdash#18086)) ([b78b7eb](lightdash@b78b7eb)) * add space access control for AI agents ([lightdash#18061](lightdash#18061)) ([b9cb25a](lightdash@b9cb25a)), closes [lightdash#18044](lightdash#18044) * improve oauth page styling ([lightdash#18075](lightdash#18075)) ([67b322e](lightdash@67b322e))

Description:
Added multi-select functionality to the Tree component, allowing users to select multiple items in a tree structure. This enhancement includes:
typeprop to specify whether the tree supports single or multiple selectionCleanShot 2025-11-13 at 12.22.06.mp4 (uploaded via Graphite)