Skip to content

Commit 765d5c7

Browse files
hellendagDagster Devtools
authored andcommitted
[ui] Replace Blueprint Collapse with Radix Collapsible (#22072)
## Summary & Motivation This PR migrates from Blueprint.js `Collapse` component to Radix UI's `react-collapsible` component across the codebase. The changes replace `@blueprintjs/core` Collapse usage with `@radix-ui/react-collapsible` in three components: - `AgentContent.tsx` - Updates the inactive agents collapsible section - `LargeCollapsibleSection.tsx` - Migrates the main collapsible section component - `SidebarComponents.tsx` - Updates the sidebar section collapse functionality The migration maintains the same functionality while moving to a more modern, accessible component library. ## Test Plan - Verify that collapsible sections in the agent health page expand/collapse correctly - Test that large collapsible sections throughout the app maintain their expand/collapse state - Ensure sidebar sections can be toggled open and closed as expected Internal-RevId: e2d04fa44c19f76e973e4164f96e840c2d2aee6b
1 parent 6cf75ff commit 765d5c7

3 files changed

Lines changed: 47 additions & 44 deletions

File tree

js_modules/ui-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@koale/useworker": "^4.1.2",
47+
"@radix-ui/react-collapsible": "^1.1.12",
4748
"@radix-ui/react-tooltip": "^1.2.8",
4849
"@tanstack/react-virtual": "^3.0.1",
4950
"@testing-library/react-hooks": "^7.0.2",
Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// eslint-disable-next-line no-restricted-imports
2-
import {Collapse} from '@blueprintjs/core';
31
import {Box, Icon, IconName, Subtitle1, UnstyledButton} from '@dagster-io/ui-components';
2+
import * as Collapsible from '@radix-ui/react-collapsible';
43
import React from 'react';
54

65
import {useStateWithStorage} from '../hooks/useStateWithStorage';
@@ -31,29 +30,35 @@ export const LargeCollapsibleSection = ({
3130
);
3231

3332
return (
34-
<Box flex={{direction: 'column'}}>
35-
<UnstyledButton onClick={() => setIsCollapsed(!isCollapsed)}>
36-
<Box
37-
flex={{direction: 'row', alignItems: 'center', gap: 6}}
38-
padding={{vertical: 12, right: 12, left: padHeader ? 24 : 0}}
39-
border="bottom"
40-
>
41-
{icon && <Icon size={20} name={icon} />}
42-
<Subtitle1 style={{flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis'}}>
43-
{header}
44-
{count !== undefined ? ` (${count.toLocaleString()})` : ''}
45-
</Subtitle1>
46-
{right}
47-
<Icon
48-
name="arrow_drop_down"
49-
size={20}
50-
style={{transform: isCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)'}}
51-
/>
52-
</Box>
53-
</UnstyledButton>
54-
<Collapse isOpen={!isCollapsed}>
55-
<Box padding={{vertical: padChildren ? 12 : 0}}>{children}</Box>
56-
</Collapse>
57-
</Box>
33+
<Collapsible.Root open={!isCollapsed} onOpenChange={(open) => setIsCollapsed(!open)}>
34+
<Box flex={{direction: 'column'}}>
35+
<Collapsible.Trigger asChild>
36+
<UnstyledButton>
37+
<Box
38+
flex={{direction: 'row', alignItems: 'center', gap: 6}}
39+
padding={{vertical: 12, right: 12, left: padHeader ? 24 : 0}}
40+
border="bottom"
41+
>
42+
{icon && <Icon size={20} name={icon} />}
43+
<Subtitle1
44+
style={{flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis'}}
45+
>
46+
{header}
47+
{count !== undefined ? ` (${count.toLocaleString()})` : ''}
48+
</Subtitle1>
49+
{right}
50+
<Icon
51+
name="arrow_drop_down"
52+
size={20}
53+
style={{transform: isCollapsed ? 'rotate(-90deg)' : 'rotate(0deg)'}}
54+
/>
55+
</Box>
56+
</UnstyledButton>
57+
</Collapsible.Trigger>
58+
<Collapsible.Content style={{overflowX: 'auto'}}>
59+
<Box padding={{vertical: padChildren ? 12 : 0}}>{children}</Box>
60+
</Collapsible.Content>
61+
</Box>
62+
</Collapsible.Root>
5863
);
5964
};

js_modules/ui-core/src/pipelines/SidebarComponents.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// eslint-disable-next-line no-restricted-imports
2-
import {Collapse} from '@blueprintjs/core';
31
import {Colors, FontFamily, Icon} from '@dagster-io/ui-components';
2+
import * as Collapsible from '@radix-ui/react-collapsible';
43
import * as React from 'react';
54
import styled from 'styled-components';
65

@@ -18,24 +17,22 @@ export const SidebarSection = (props: ISidebarSectionProps) => {
1817
storedValue === true || storedValue === false ? storedValue : !collapsedByDefault,
1918
);
2019

21-
const onToggle = React.useCallback(() => {
22-
setOpen((o) => !o);
23-
}, [setOpen]);
24-
2520
return (
26-
<>
27-
<CollapsingHeaderBar onClick={onToggle}>
28-
<SidebarTitleTextWrap>{title}</SidebarTitleTextWrap>
29-
<Icon
30-
size={24}
31-
name="arrow_drop_down"
32-
style={{transform: open ? 'rotate(0)' : 'rotate(-90deg)'}}
33-
/>
34-
</CollapsingHeaderBar>
35-
<Collapse isOpen={open}>
21+
<Collapsible.Root open={open} onOpenChange={setOpen}>
22+
<Collapsible.Trigger asChild>
23+
<CollapsingHeaderBar>
24+
<SidebarTitleTextWrap>{title}</SidebarTitleTextWrap>
25+
<Icon
26+
size={24}
27+
name="arrow_drop_down"
28+
style={{transform: open ? 'rotate(0)' : 'rotate(-90deg)'}}
29+
/>
30+
</CollapsingHeaderBar>
31+
</Collapsible.Trigger>
32+
<Collapsible.Content style={{overflowX: 'auto'}}>
3633
<div>{children}</div>
37-
</Collapse>
38-
</>
34+
</Collapsible.Content>
35+
</Collapsible.Root>
3936
);
4037
};
4138

0 commit comments

Comments
 (0)