Skip to content

Commit 10ecce9

Browse files
fix: toolbar does not collapse when used inside flex containers (#963)
* fix: add width 100% to toolbar container to enable overflow detection * fix: add min-width: 0 to HeaderLeftContainer for proper flex shrinking * chore: update the toolbar story
1 parent d771fa8 commit 10ecce9

File tree

3 files changed

+44
-34
lines changed

3 files changed

+44
-34
lines changed

src/components/header/PanelHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const HeaderLeftContainer = styled.div`
2323
display: flex;
2424
flex-direction: row;
2525
flex: 1;
26+
min-width: 0;
2627
2728
'& > button:' {
2829
padding: 0 5px;

src/components/toolbar/Toolbar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const Container = styled.div<ContainerProps>`
8888
return placement === 'start' ? 'row-reverse' : 'row';
8989
}};
9090
overflow: hidden;
91+
width: 100%;
9192
`;
9293

9394
export const ToolbarButton = styled(Button)`

stories/components/toolbar.stories.tsx

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import type {
1313
TooltipItem,
1414
} from '../../src/components/index.js';
1515
import {
16+
Accordion,
17+
PanelHeader,
1618
SplitPane,
1719
Toolbar,
1820
TooltipHelpContent,
@@ -435,40 +437,46 @@ export function HorizontalMore() {
435437
)}
436438
</div>
437439
<div style={{ width: '100%' }}>
438-
<Toolbar intent="primary" disabled={false} overflow="collapse">
439-
{itemsBlueprintIcons.map((item) => (
440-
<Toolbar.Item
441-
key={item.id}
442-
id={item.id}
443-
tooltip={item.tooltip}
444-
active={selected === item.id}
445-
onClick={() => {
446-
setSelected(item.id);
447-
}}
448-
icon={item.icon}
449-
intent={item.id === 'test5' ? 'danger' : undefined}
450-
disabled={item.disabled ?? undefined}
451-
/>
452-
))}
453-
{itemsPopover.map(({ content, ...itemProps }) => (
454-
<Toolbar.PopoverItem
455-
key={itemProps.id}
456-
content={content}
457-
itemProps={{
458-
...itemProps,
459-
active: selected === itemProps.id,
460-
onClick: () => {
461-
setSelected(itemProps.id);
462-
},
463-
tag: itemProps.id.startsWith('credit-card')
464-
? 1
465-
: itemProps.id.startsWith('clipboard')
466-
? 15
467-
: undefined,
468-
}}
469-
/>
470-
))}
471-
</Toolbar>
440+
<Accordion>
441+
<Accordion.Item title="test" id="test" open>
442+
<PanelHeader total={10}>
443+
<Toolbar intent="primary" overflow="collapse">
444+
{itemsBlueprintIcons.map((item) => (
445+
<Toolbar.Item
446+
key={item.id}
447+
id={item.id}
448+
tooltip={item.tooltip}
449+
active={selected === item.id}
450+
onClick={() => {
451+
setSelected(item.id);
452+
}}
453+
icon={item.icon}
454+
intent={item.id === 'test5' ? 'danger' : undefined}
455+
disabled={item.disabled ?? undefined}
456+
/>
457+
))}
458+
{itemsPopover.map(({ content, ...itemProps }) => (
459+
<Toolbar.PopoverItem
460+
key={itemProps.id}
461+
content={content}
462+
itemProps={{
463+
...itemProps,
464+
active: selected === itemProps.id,
465+
onClick: () => {
466+
setSelected(itemProps.id);
467+
},
468+
tag: itemProps.id.startsWith('credit-card')
469+
? 1
470+
: itemProps.id.startsWith('clipboard')
471+
? 15
472+
: undefined,
473+
}}
474+
/>
475+
))}
476+
</Toolbar>
477+
</PanelHeader>
478+
</Accordion.Item>
479+
</Accordion>
472480
</div>
473481
</SplitPane>
474482
);

0 commit comments

Comments
 (0)