Skip to content

Commit c51fec3

Browse files
committed
UI: Finish removing breaking changes from a11y branch
1 parent 9167f42 commit c51fec3

File tree

21 files changed

+1248
-318
lines changed

21 files changed

+1248
-318
lines changed

MIGRATION.md

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,11 @@
2424
- [TabButton is deprecated](#tabbutton-is-deprecated)
2525
- [TabBar is deprecated](#tabbar-is-deprecated)
2626
- [Modal Component API Changes](#modal-component-api-changes)
27-
- [Removed: container and portalSelector](#removed-container-and-portalselector)
28-
- [Removed: onInteractOutside](#removed-oninteractoutside)
29-
- [Removed: onEscapeKeyDown](#removed-onescapekeydown)
27+
- [Deprecated: onInteractOutside](#deprecated-oninteractoutside)
28+
- [Deprecated: onEscapeKeyDown](#deprecated-onescapekeydown)
3029
- [Added: `ariaLabel`](#added-arialabel-1)
3130
- [Renamed: Modal.Dialog.Close and Modal.CloseButton](#renamed-modaldialogclose-and-modalclosebutton)
3231
- [ListItem, TooltipLinkList and TooltipMessage are deprecated](#listitem-tooltiplinklist-and-tooltipmessage-are-deprecated)
33-
- [Tooltip Component API Changes](#tooltip-component-api-changes)
34-
- [Renamed: tooltipRef](#renamed-tooltipref)
35-
- [Removed: arrowProps and withArrows](#removed-arrowprops-and-witharrows)
36-
- [Removed: placement](#removed-placement)
37-
- [Changed type: color](#changed-type-color)
3832
- [WithPopover Component Added](#withpopover-component-added)
3933
- [WithTooltip Component API Changes](#withtooltip-component-api-changes)
4034
- [Removed: trigger](#removed-trigger)
@@ -45,7 +39,7 @@
4539
- [Removed: closeOnTriggerHidden, followCursor, closeOnOutsideClick](#removed-closeontriggerhidden-followcursor-closeonoutsideclick)
4640
- [Removed: interactive](#removed-interactive)
4741
- [Other changes](#other-changes)
48-
- [WithTooltipPure and WithTooltipState are removed](#withtooltippure-and-withtooltipstate-are-removed)
42+
- [WithTooltipPure and WithTooltipState are deprecated](#withtooltippure-and-withtooltipstate-are-deprecated)
4943
- [From version 8.x to 9.0.0](#from-version-8x-to-900)
5044
- [Core Changes and Removals](#core-changes-and-removals)
5145
- [Dropped support for legacy packages](#dropped-support-for-legacy-packages)
@@ -657,7 +651,7 @@ IconButton will be removed in future versions.
657651

658652
#### Bar Component API Changes
659653

660-
The `Bar` component's internal layout has changed. It now applies flex positioning and applies a default item gap, that can be controlled with the `innerStyle` prop.
654+
The `Bar` component's internal layout has changed, to fix a height bug in scrollable bars. It now applies flex positioning and applies a default item gap, that can be controlled with the `innerStyle` prop. You may see slight changes in default padding as a result of this change.
661655

662656
##### Added: innerStyle
663657
When `scrollable` is set to `true`, `Bar` now adds an inner container that is used to ensure the scrollbar size does not impact the height of the bar. This inner container displays as 'flex' and has the following default style:
@@ -699,14 +693,11 @@ The `TabBar` component, a styled bar used inside `Tabs` and not intended to be p
699693

700694
#### Modal Component API Changes
701695

702-
##### Removed: container and portalSelector
703-
The `container` and `portalSelector` props were not used inside Storybook, so they have been removed. The new Modal component does not support custom portal locations, because it is not recommended practice. A single portal at the end of the document ensures modals appear in their order of creation and are never cropped by CSS `overflow` properties.
696+
##### Deprecated: onInteractOutside
697+
The `onInteractOutside` prop is deprecated in favor of `dismissOnClickOutside`, because it was only used to close the modal when clicking outside. Use `dismissOnClickOutside` to control whether clicking outside the modal should close it or not.
704698

705-
##### Removed: onInteractOutside
706-
The `onInteractOutside` prop is removed in favor of `dismissOnClickOutside`, because it was only used to close the modal when clicking outside. Use `dismissOnClickOutside` to control whether clicking outside the modal should close it or not.
707-
708-
##### Removed: onEscapeKeyDown
709-
The `onEscapeKeyDown` prop is removed in favor of `dismissOnEscape`, because it was only used to close the modal when pressing Escape. Use `dismissOnEscape` to control whether pressing Escape should close it or not.
699+
##### Deprecated: onEscapeKeyDown
700+
The `onEscapeKeyDown` prop is deprecated in favor of `dismissOnEscape`, because it was only used to close the modal when pressing Escape. Use `dismissOnEscape` to control whether pressing Escape should close it or not.
710701

711702
##### Added: `ariaLabel`
712703
Modal elements must have a title to be accessible. Set that title through the `ariaLabel` prop. It will become mandatory in Storybook 11.
@@ -721,24 +712,6 @@ The ListItem and TooltipLinkList components were used in Storybook to make menus
721712

722713
These components are now deprecated and will be removed in future versions. To replace TooltipMessage, replace WithTooltip with WithPopover, and use Popover as a base component for your popovers. To replace ListItem and TooltipLinkList, a dedicated menu component will be introduced in a future version, and Popover can be used in the meantime.
723714

724-
#### Tooltip Component API Changes
725-
726-
##### Renamed: tooltipRef
727-
Tooltip's `ref` prop is now named `ref` for consistency.
728-
729-
##### Removed: arrowProps and withArrows
730-
The `arrowProps` and `withArrows` props were not used in Storybook, so they have been removed.
731-
732-
We recommend you do not use arrows in your addon tooltips for better consistency with the Storybook UI.
733-
734-
##### Removed: placement
735-
The `placement` prop was passed to help position the arrow. It has also been removed. WithToolip now entirely handles the placement of its tooltip on its own.
736-
737-
##### Changed type: color
738-
The `color` prop used to accept arbitrary colors and theme background color names. This made it difficult to use.
739-
740-
The prop was to the background color of the tooltip, and it was not possible to set the text color in a consistent fashion. To ensure Tooltip uses accessible colors, the prop has been limited to the following values: `'default'`, `'inverse'`, `'positive'`, `'negative'`, `'warning'` and `'none'`. The prop now controls both background and foreground colors.
741-
742715
#### WithPopover Component Added
743716

744717
The WithPopover component acts as a counterpoint to WithTooltip. When you want an interactive overlay with buttons or inputs, use WithPopover and Popover. When you want a static overlay that shows on focus or hover, use WithTooltip with TooltipNote or Tooltip.
@@ -747,6 +720,8 @@ WithPopover is based on react-aria. It must have a single child that acts as a t
747720

748721
#### WithTooltip Component API Changes
749722

723+
The WithTooltip component has been reimplemented from the ground up. The new implementation is exported as `WithTooltipNew` in Storybook 10, and will replace `WithTooltip` entirely in Storybook 11. Below is a summary of the changes between both APIs, which will take full effect in Storybook 11.
724+
750725
##### Removed: trigger
751726
The `trigger` prop was removed to enforce better accessibility compliance. WithTooltip must not be triggered on click, as it is not reachable by keyboard. Buttons that open a popover, menu or select must use appropriate components instead.
752727

@@ -771,9 +746,9 @@ Thed `interactive` prop has been removed as it does not align with our vision fo
771746
##### Other changes
772747
The underlying implementation was switched from Popper.js to react-aria. Due to these changes, WithTooltip must now have a single child that has a focusable role and that can receive React refs. Wrap your trigger component in `forwardRef` if you notice placement issues for your tooltip.
773748

774-
#### WithTooltipPure and WithTooltipState are removed
749+
#### WithTooltipPure and WithTooltipState are deprecated
775750

776-
Instead, use WithTooltip. For a controlled tooltip, use the `onVisibleChange` and `visible` props. For an uncontrolled tooltip with a default open state, use the `defaultVisible` prop.
751+
Instead, use `WithTooltipNew` in Storybook 10, or `WithTooltip` in Storybook 11 or newer. For a controlled tooltip, use the `onVisibleChange` and `visible` props. For an uncontrolled tooltip with a default open state, use the `defaultVisible` prop.
777752

778753
## From version 8.x to 9.0.0
779754

code/addons/docs/src/blocks/components/ArgsTable/ArgValue.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { FC } from 'react';
22
import React, { useState } from 'react';
33

4-
import { SyntaxHighlighter, WithTooltip, codeCommon } from 'storybook/internal/components';
4+
import { SyntaxHighlighter, WithTooltipNew, codeCommon } from 'storybook/internal/components';
55

66
import { ChevronSmallDownIcon, ChevronSmallUpIcon } from '@storybook/icons';
77

@@ -171,7 +171,7 @@ const ArgSummary: FC<ArgSummaryProps> = ({ value, initialExpandedArgs }) => {
171171
}
172172

173173
return (
174-
<WithTooltip
174+
<WithTooltipNew
175175
placement="bottom"
176176
visible={isOpen}
177177
onVisibleChange={(isVisible) => {
@@ -189,7 +189,7 @@ const ArgSummary: FC<ArgSummaryProps> = ({ value, initialExpandedArgs }) => {
189189
<span>{summaryAsString}</span>
190190
{isOpen ? <ChevronUpIcon /> : <ChevronDownIcon />}
191191
</Expandable>
192-
</WithTooltip>
192+
</WithTooltipNew>
193193
);
194194
};
195195

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import React from 'react';
2+
3+
import preview from '../../../../../.storybook/preview';
4+
import { Bar } from './Bar';
5+
6+
const meta = preview.meta({
7+
component: Bar,
8+
title: 'Bar/Bar',
9+
decorators: [
10+
(Story) => (
11+
<div style={{ background: 'blue', border: '1px solid purple', maxWidth: 500, height: 200 }}>
12+
<Story />
13+
</div>
14+
),
15+
],
16+
});
17+
18+
export default meta;
19+
20+
const LongContent = () =>
21+
Array.from({ length: 12 }).map((_, i) => (
22+
<div key={i} style={{ padding: '0 8px' }}>
23+
Item {i + 1}
24+
</div>
25+
));
26+
27+
export const Default = meta.story({ args: { children: 'Default' } });
28+
29+
export const Bordered = meta.story({
30+
args: { border: true, children: 'Bar with border' },
31+
});
32+
33+
export const BackgroundBorderless = meta.story({
34+
args: { backgroundColor: '#f3f4f6', border: false, children: 'Bar with custom background' },
35+
});
36+
37+
export const BackgroundBordered = meta.story({
38+
args: { backgroundColor: '#f3f4f6', border: true, children: 'Bar with custom background' },
39+
});
40+
41+
export const NonScrollable = meta.story({
42+
name: 'Non-scrollable',
43+
args: {
44+
children: 'Non-scrollable Bar',
45+
scrollable: false,
46+
},
47+
});
48+
49+
export const Scrollable = meta.story({
50+
args: { scrollable: true, children: <LongContent /> },
51+
});
52+
53+
export const ScrollableBordered = meta.story({
54+
name: 'Scrollable bordered',
55+
args: {
56+
border: true,
57+
children: <LongContent />,
58+
innerStyle: { justifyContent: 'start' },
59+
scrollable: true,
60+
},
61+
});
62+
63+
export const ScrollableBackground = meta.story({
64+
name: 'Scrollable background',
65+
args: {
66+
backgroundColor: '#f3f4f6',
67+
border: false,
68+
children: <LongContent />,
69+
innerStyle: { justifyContent: 'start' },
70+
scrollable: true,
71+
},
72+
});
73+
74+
export const ScrollableBackgroundBordered = meta.story({
75+
name: 'Scrollable background bordered',
76+
args: {
77+
backgroundColor: '#f3f4f6',
78+
border: true,
79+
children: <LongContent />,
80+
innerStyle: { justifyContent: 'start' },
81+
scrollable: true,
82+
},
83+
});
84+
85+
export const InnerStyleOverride = meta.story({
86+
args: {
87+
children: <div style={{ padding: '0 8px' }}>Custom inner style</div>,
88+
innerStyle: { backgroundColor: '#fff7ed', gap: 12 },
89+
},
90+
});

code/core/src/components/components/Bar/Bar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ const StyledBar = styled.div<BarProps>(
1919
width: '100%',
2020
minHeight: 40,
2121
flexShrink: 0,
22-
scrollbarColor: `${theme.barTextColor} ${backgroundColor || theme.barBg}`,
22+
// TODO in Storybook 11: Apply background regardless of border.
23+
scrollbarColor: `${theme.barTextColor} ${border ? backgroundColor || theme.barBg : 'transparent'}`,
2324
scrollbarWidth: 'thin',
2425
overflow: scrollable ? 'auto' : 'hidden',
2526
overflowY: 'hidden',
2627
display: 'flex',
2728
alignItems: 'center',
2829
gap: scrollable ? 0 : 6,
2930
paddingInline: scrollable ? 0 : 6,
31+
// TODO in Storybook 11: Apply background regardless of border.
3032
...(border
3133
? {
3234
boxShadow: `${theme.appBorderColor} 0 -1px 0 0 inset`,
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import React from 'react';
2+
3+
import { styled } from 'storybook/theming';
4+
5+
import preview from '../../../../../.storybook/preview';
6+
import { FlexBar } from './Bar';
7+
8+
const meta = preview.meta({ component: FlexBar, title: 'Bar/FlexBar (deprecated)' });
9+
10+
export default meta;
11+
12+
const Row = styled.div({
13+
display: 'flex',
14+
alignItems: 'center',
15+
gap: 4,
16+
});
17+
18+
const LongContent = () =>
19+
Array.from({ length: 12 }).map((_, i) => (
20+
<div key={i} style={{ padding: '0 8px' }}>
21+
Item {i + 1}
22+
</div>
23+
));
24+
25+
export const Default = meta.story({
26+
render: (args) => (
27+
<FlexBar {...args}>
28+
<Row>Left content</Row>
29+
<Row>Right content</Row>
30+
</FlexBar>
31+
),
32+
});
33+
34+
export const OnlyLeft = meta.story({
35+
render: (args) => (
36+
<FlexBar {...args}>
37+
<Row>Only left</Row>
38+
</FlexBar>
39+
),
40+
});
41+
42+
export const OnlyRight = meta.story({
43+
render: (args) => (
44+
<FlexBar {...args}>
45+
<Row></Row>
46+
<Row>Only right</Row>
47+
</FlexBar>
48+
),
49+
});
50+
51+
export const Background = meta.story({
52+
args: {
53+
backgroundColor: '#f3f4f6',
54+
},
55+
render: (args) => (
56+
<FlexBar {...args}>
57+
<Row>Left content</Row>
58+
<Row>Right content</Row>
59+
</FlexBar>
60+
),
61+
});
62+
63+
export const Border = meta.story({
64+
args: {
65+
border: true,
66+
},
67+
render: (args) => (
68+
<FlexBar {...args}>
69+
<Row>Left content</Row>
70+
<Row>Right content</Row>
71+
</FlexBar>
72+
),
73+
});
74+
75+
export const BackgroundBorder = meta.story({
76+
args: {
77+
backgroundColor: '#f3f4f6',
78+
border: true,
79+
},
80+
render: (args) => (
81+
<FlexBar {...args}>
82+
<Row>Left content</Row>
83+
<Row>Right content</Row>
84+
</FlexBar>
85+
),
86+
});
87+
88+
export const ScrollableBackground = meta.story({
89+
args: {
90+
backgroundColor: '#f3f4f6',
91+
scrollable: true,
92+
},
93+
render: (args) => (
94+
<FlexBar {...args}>
95+
<Row>
96+
<LongContent />
97+
</Row>
98+
<Row>
99+
<LongContent />
100+
</Row>
101+
</FlexBar>
102+
),
103+
});
104+
105+
export const ScrollableBorder = meta.story({
106+
args: {
107+
border: true,
108+
scrollable: true,
109+
},
110+
render: (args) => (
111+
<FlexBar {...args}>
112+
<Row>
113+
<LongContent />
114+
</Row>
115+
<Row>
116+
<LongContent />
117+
</Row>
118+
</FlexBar>
119+
),
120+
});
121+
122+
export const ScrollableBackgroundBorder = meta.story({
123+
args: {
124+
backgroundColor: '#f3f4f6',
125+
border: true,
126+
scrollable: true,
127+
},
128+
render: (args) => (
129+
<FlexBar {...args}>
130+
<Row>
131+
<LongContent />
132+
</Row>
133+
<Row>
134+
<LongContent />
135+
</Row>
136+
</FlexBar>
137+
),
138+
});

0 commit comments

Comments
 (0)