@splunk/react-ui 5.0.0-rc.2 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +361 -0
- package/ControlGroup.js +1 -1
- package/Dropdown.js +9 -9
- package/MIGRATION.md +550 -1
- package/Message.js +47 -43
- package/ModalLayer.js +15 -11
- package/Multiselect.js +90 -84
- package/Popover.js +117 -114
- package/README.md +6 -6
- package/ResultsMenu.js +116 -115
- package/Select.js +10 -8
- package/TransitionOpen.js +4 -1
- package/package.json +10 -10
- package/types/src/Dropdown/Dropdown.d.ts +1 -0
- package/types/src/Popover/Popover.d.ts +7 -1
- package/types/src/ResultsMenu/ResultsMenu.d.ts +2 -1
- package/CHANGELOG.v5.md +0 -354
- package/MIGRATION.v5.md +0 -552
- package/types/src/Button/docs/examples/Truncated.d.ts +0 -3
package/MIGRATION.md
CHANGED
|
@@ -2,11 +2,560 @@
|
|
|
2
2
|
|
|
3
3
|
This document lists migration guidance for new features and breaking changes.
|
|
4
4
|
|
|
5
|
+
## 5.0.0
|
|
6
|
+
|
|
7
|
+
### Component spacing
|
|
8
|
+
|
|
9
|
+
To unify the styling of components margin has been removed and components should not have any spacing outside of its border box.
|
|
10
|
+
|
|
11
|
+
#### Content components
|
|
12
|
+
|
|
13
|
+
Some components had `margin-bottom` by default: e.g. `Heading` or `Paragraph`. Although this could
|
|
14
|
+
simplify styling with text content, often it needed to be overridden when using these
|
|
15
|
+
components in an application. Additionally, it was not consistent which components
|
|
16
|
+
would have the additional spacing.
|
|
17
|
+
|
|
18
|
+
When spacing is needed in long-form text content the new `Prose` component can be used to add styling that optimizes for readability.
|
|
19
|
+
|
|
20
|
+
#### inline margin
|
|
21
|
+
|
|
22
|
+
Previously, certain components automatically applied a `margin-left` when siblings with other components (e.g., two `Button`s, or a `Text` and a `Button`). This behavior worked fine for basic use cases where no additional styling was needed for spacing.
|
|
23
|
+
|
|
24
|
+
However, it created issues in more complex layouts, especially with modern techniques like flex and grid, requiring developers to manually reset the margin. To be consistent with removing margin outside components' border box and encourage modern layout practices, this automatic margin has been removed. The `inline` attribute remains, and it still affects the display and width of certain components.
|
|
25
|
+
|
|
26
|
+
For spacing between components, use the new `Layout` component, which applies spacing without relying on margin. If you’re already using a wrapper, you can instead use `@splunk/themes/mixins/layout` to manage spacing, allowing you to remove previous margin overrides.
|
|
27
|
+
|
|
28
|
+
### Component font styles
|
|
29
|
+
|
|
30
|
+
#### New features and changes
|
|
31
|
+
|
|
32
|
+
- The font size and line height no longer change with density (SUI-5508).
|
|
33
|
+
- The default font-size in Enterprise Compact now is 14px (SUI-5508).
|
|
34
|
+
|
|
35
|
+
#### Migration steps for font-size, font-weight and font-family
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
css`font-size: ${variables.fontSizeSmall}`
|
|
39
|
+
is equivalent to
|
|
40
|
+
css`font-size: ${mixins.typography({ size: 12 })}`
|
|
41
|
+
|
|
42
|
+
css`font-size: ${variables.fontWeightSemiBold}`
|
|
43
|
+
is equivalent to
|
|
44
|
+
css`font-weight: ${mixins.typography({ weight: 'semiBold' })}`
|
|
45
|
+
|
|
46
|
+
css`font-family: ${variables.sansFontFamily}`
|
|
47
|
+
is equivalent to
|
|
48
|
+
css`font-family: ${mixins.typography({ family: 'sansSerif' })}`
|
|
49
|
+
|
|
50
|
+
css`line-height: ${variables.lineHeight}`
|
|
51
|
+
is equivalent to
|
|
52
|
+
css`font-size: ${mixins.typography({ lineHeight: 20 })}`
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Monogram to Avatar
|
|
56
|
+
|
|
57
|
+
`Monogram` will be removed in a future major version. Use `Avatar` instead (SUI-5608).
|
|
58
|
+
|
|
59
|
+
#### New features and changes
|
|
60
|
+
|
|
61
|
+
- `Avatar` supports images via `image` prop (SUI-3227).
|
|
62
|
+
- `Avatar`'s `value` prop replaces `Monogram`'s `name` prop (SUI-5610).
|
|
63
|
+
- `Avatar`'s `size` prop doesn't have an `"xlarge"` option (SUI-5518).
|
|
64
|
+
- `Avatar`'s `size` prop supports `string` instead of `number` (SUI-5615).
|
|
65
|
+
- `Avatar`'s `"medium"` size is `32px` and `large` size is `48px` (SUI-5615).
|
|
66
|
+
- `Avatar` has the same sizes in Enterprise and Prisma theme (SUI-5617).
|
|
67
|
+
- `Avatar` requires `label` prop (SUI-5611).
|
|
68
|
+
- `Avatar`'s text color will change automatically depending on the background color to comply with accessibility contrast requirements (SUI-5614).
|
|
69
|
+
- `Avatar`'s `backgroundColor` prop doesn't have a `"theme"` option (SUI-5614). No value for `backgroundColor` is needed for the default background colors.
|
|
70
|
+
|
|
71
|
+
#### Migration steps
|
|
72
|
+
|
|
73
|
+
###### `size` prop
|
|
74
|
+
|
|
75
|
+
```jsx
|
|
76
|
+
<Monogram size="medium" /> is equivalent to <Avatar size='large'/>
|
|
77
|
+
<Monogram size="large" /> is equivalent to <Avatar size='80px'/>
|
|
78
|
+
<Monogram size="xlarge" /> is equivalent to <Avatar size='144px'/>
|
|
79
|
+
|
|
80
|
+
Convert any usage of a number type to string type:
|
|
81
|
+
<Monogram size={40} /> is equivalent to <Avatar size='40px'/>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
###### `name` prop
|
|
85
|
+
|
|
86
|
+
```jsx
|
|
87
|
+
<Monogram initials="A" name="Amelia" onClick={() => {}} />
|
|
88
|
+
is equivalent to
|
|
89
|
+
<Avatar initials="A" value="Amelia" onClick={() => {}}/>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Change to `Modal.Header` icon
|
|
93
|
+
|
|
94
|
+
`Modal.Header`'s `icon` prop no longer requires `width="100%" height="100%"` to be set on the icon to render at the correct size (SUI-5931).
|
|
95
|
+
|
|
96
|
+
#### Migration steps
|
|
97
|
+
|
|
98
|
+
Remove `width="100%" height="100%"` from the icon.
|
|
99
|
+
|
|
100
|
+
### Changes to `Modal` and `Modal.Header` `onRequestClose` prop
|
|
101
|
+
|
|
102
|
+
`Modal.Header` now uses the `onRequestClose` prop from `Modal` and no longer supports its own `onRequestClose`.
|
|
103
|
+
When the `Modal` is closed by clicking the "close" button in Modal.Header` the `reason` parameter will be `"clickCloseButton"` (SUI-5933).
|
|
104
|
+
|
|
105
|
+
For cases where `onRequestClose` was not set on `Modal.Header`, the "close" button can be hidden with the new `hideCloseButton` prop to maintain prior behavior.
|
|
106
|
+
|
|
107
|
+
#### Migration steps
|
|
108
|
+
|
|
109
|
+
If `onRequestClose` was set on `Modal.Header`, remove it and either add the `onRequestClose` to `Modal` or update it if it exists. If it's necessary to determine if the prop was called by the "close" button in `Modal.Header`, the `reason` parameter will be set to `"`clickCloseButton`" in those cases.
|
|
110
|
+
If `onRequestClose` was not set on `Modal.Header`, add the new `hideCloseButton` prop to maintain prior behavior.
|
|
111
|
+
|
|
112
|
+
### `JSONTree`'s `expandChildren` prop renamed to `defaultExpanded` and no longer affects node expansion behavior after the initial render.
|
|
113
|
+
|
|
114
|
+
#### Change
|
|
115
|
+
|
|
116
|
+
`JSONTree`'s `expandChildren` prop has been renamed to `defaultExpanded` and no longer affects node expansion behavior after the initial render.
|
|
117
|
+
|
|
118
|
+
#### Context
|
|
119
|
+
|
|
120
|
+
The old behavior of `JSONTree`'s `expandChildren` prop was to:
|
|
121
|
+
1. Start with all nodes expanded.
|
|
122
|
+
2. Always expand all descendant nodes when a node is expanded.
|
|
123
|
+
|
|
124
|
+
Now `expandChildren` has been renamed to `defaultExpanded` and the behavior of `defaultExpanded` is to:
|
|
125
|
+
1. Start with all nodes expanded. This behavior remains the same as `expandChildren`.
|
|
126
|
+
2. Subsequent node expansions are not affected by `defaultExpanded` - they only expand one level of nodes. This behavior is different from `expandChildren`'s old behavior.
|
|
127
|
+
|
|
128
|
+
This change in behavior was made because it was likely not a desired behavior and unintuitive that `expandChildren` would always expand all descendant nodes.
|
|
129
|
+
Then `expandChildren` was renamed to `defaultExpanded` to make it clear it does not affect node expansion behavior after the initial render.
|
|
130
|
+
|
|
131
|
+
#### Migration steps
|
|
132
|
+
|
|
133
|
+
Replace all usage of `JSONTree`'s `expandChildren` prop with `defaultExpanded`.
|
|
134
|
+
To expand all descendant nodes when a node is expanded, use the `expandChildrenOnShiftKey` prop instead.
|
|
135
|
+
|
|
136
|
+
### `ComboBox`, `Date`, `Multiselect`, `Number`, `Search`, `Select`, and `Text` no longer use the TypeScript `HTMLTextAreaElement` type in event handlers and refs
|
|
137
|
+
|
|
138
|
+
#### Change
|
|
139
|
+
|
|
140
|
+
`ComboBox`, `Date`, `Multiselect`, `Number`, `Search`, `Select`, and `Text` no longer use the TypeScript `HTMLTextAreaElement` type in event handlers.
|
|
141
|
+
`Number` and `Text` no longer use the TypeScript `HTMLTextAreaElement` type for the `inputRef` prop (SUI-6206).
|
|
142
|
+
|
|
143
|
+
#### Context
|
|
144
|
+
|
|
145
|
+
`Text`'s `multiline` prop was removed. With this change, it is no longer necessary for `Text` and components that use `Text` to
|
|
146
|
+
have props that include the TypeScript `HTMLTextAreaElement` type.
|
|
147
|
+
|
|
148
|
+
#### Migration steps
|
|
149
|
+
* Change the callbacks passed into the following props to use an event type that doesn't include `HTMLTextAreaElement`:
|
|
150
|
+
* `ComboBox`
|
|
151
|
+
* `onBlur`
|
|
152
|
+
* `onChange`
|
|
153
|
+
* `onFocus`
|
|
154
|
+
* `Date`
|
|
155
|
+
* `onBlur`
|
|
156
|
+
* `onFocus`
|
|
157
|
+
* `Multiselect`
|
|
158
|
+
* `onFilterChange`
|
|
159
|
+
* `Number`
|
|
160
|
+
* `onBlur`
|
|
161
|
+
* `onChange`
|
|
162
|
+
* `onFocus`
|
|
163
|
+
* `Search`
|
|
164
|
+
* `onBlur`
|
|
165
|
+
* `onChange`
|
|
166
|
+
* `onFocus`
|
|
167
|
+
* `Select`
|
|
168
|
+
* `onFilterChange`
|
|
169
|
+
* `Text`
|
|
170
|
+
* `onBlur`
|
|
171
|
+
* `onClick`
|
|
172
|
+
* `onChange`
|
|
173
|
+
* `onFocus`
|
|
174
|
+
* `onKeyDown`
|
|
175
|
+
* `onSelect`
|
|
176
|
+
* Change any refs passed into `Text` and `Number`'s `inputRef` prop with the TypeScript `HTMLTextAreaElement` type to be of `HTMLInputElement` type instead.
|
|
177
|
+
|
|
178
|
+
### `Text`, `Date`, and `Number` `onClick` prop API changes
|
|
179
|
+
|
|
180
|
+
#### Change
|
|
181
|
+
- `Text`'s `onInputClick` prop has been renamed to `onClick`.
|
|
182
|
+
- `Date`'s `onClick` prop now uses Typescript `HTMLInputElement` type.
|
|
183
|
+
- `Number` supports new `onClick` prop with TypeScript `HTMLInputElement` type.
|
|
184
|
+
|
|
185
|
+
#### Context
|
|
186
|
+
|
|
187
|
+
`Text`'s `onClick` prop was applied to the wrapping element rather than the `input` element itself.
|
|
188
|
+
This caused difficulty disambiguating clicks on the `input` from clicks on other parts of the component, such as adornments.
|
|
189
|
+
To provide a temporary solution without breaking changes, an `onInputClick` prop was added for clicks on the `input` itself.
|
|
190
|
+
In 5.0, we're fixing the issue and removing the workaround, so `onClick` will now be applied directly to the `input` element,
|
|
191
|
+
which will result in a change to the TypeScript types.
|
|
192
|
+
`Date` and `Number` components will leverage the new callback, so their types will change to match.
|
|
193
|
+
|
|
194
|
+
#### Migration steps
|
|
195
|
+
|
|
196
|
+
- Replace all usage of `Text`'s `onInputClick` prop with `onClick`.
|
|
197
|
+
- Change callbacks passed to `Date`'s `onClick` prop to use an event with the TypeScript `HTMLInputElement` type.
|
|
198
|
+
- Change callbacks passed to `Number`'s `onClick` prop to use an event with the TypeScript `HTMLInputElement` type.
|
|
199
|
+
|
|
200
|
+
### `Collapsible Panel`, `Color`, `ControlGroup`, `Dropdown`, `Image`, `Link `, `Menu`, `Modal`, `Switch`, and `Text` converted to functional components
|
|
201
|
+
|
|
202
|
+
#### Change
|
|
203
|
+
`Collapsible Panel`, `Color`, `ControlGroup`, `File`, `Image`, `Link `, `Menu`, `Modal`, `Select.Option`, `Slider`, `SlidingPanel.Panel`, `Switch`, `Table.HeadDropdownCell`, and `Text` converted from class to functional components.
|
|
204
|
+
|
|
205
|
+
#### Context
|
|
206
|
+
React recommends defining components as functions instead of classes. Functional components don't have `ref` support.
|
|
207
|
+
Components that formerly supported class focus methods (`Color`, `Link`, `Menu`, `Number`, `Select.Option`, `Switch`, `TabBar.Tab`, `Table.HeadDropdownCell`, `Text`) no longer do so.
|
|
208
|
+
|
|
209
|
+
#### Migration steps
|
|
210
|
+
- Convert all usage of `ref` to `elementRef`.
|
|
211
|
+
- For `Number` and `Text`: Replace all usage of the class `focus` method with passing a `ref` to the `inputRef` prop and calling `inputRef.current.focus()`.
|
|
212
|
+
- For `Button`, `Color`, `Link`, `Menu`, `Multiselect.Option`, `Select.Option`, `SplitButton.Item`, and `TabBar.Tab`: Replace all usage of the class `focus` method with passing a `ref` to the `elementRef` prop and calling `elementRef.current.focus()`.
|
|
213
|
+
- For `Table.HeadDropdownCell`: Replace all usage of the class `focus` method with passing a `ref` to the `buttonRef` prop and calling `buttonRef.current.focus()`.
|
|
214
|
+
- For `Switch`: Replace all usage of the class `focus` method with passing a `ref` to the `toggleRef` prop and calling `toggleRef.current.focus()`.
|
|
215
|
+
- For `Slider`: Replace all usage of the class `focus` method with passing a `ref` to the `thumbRef` prop and calling `thumbRef.current.focus()`.
|
|
216
|
+
- For `Dropdown`: Replace all usage of the class `focus` method with passing `focus()` on the element passed to `toggle`.
|
|
217
|
+
|
|
218
|
+
### `Table.HeadDropdownCell`'s `defaultPlacement` prop has been removed
|
|
219
|
+
|
|
220
|
+
#### Change
|
|
221
|
+
`Table.HeadDropdownCell` no longer accepts a `defaultPlacement` prop.
|
|
222
|
+
|
|
223
|
+
#### Context
|
|
224
|
+
Previously `Table.HeadDropdownCell` accepted (and passed down to its `Popover` instance) a `defaultPlacement` prop. To avoid layout and positioning issues this is no longer able to be overridden in favor of only supporting `bottom` placement of the `Table.HeadDropdownCell`'s `Popover`.
|
|
225
|
+
|
|
226
|
+
#### Migration steps
|
|
227
|
+
- Remove any passing of `defaultPlacement` prop to `Table.HeadDropdownCell`
|
|
228
|
+
|
|
229
|
+
### Deprecated `RadioList`'s `direction` prop
|
|
230
|
+
|
|
231
|
+
#### Change
|
|
232
|
+
`RadioList`'s `direction` prop has been deprecated and will be removed in the next major version.
|
|
233
|
+
|
|
234
|
+
#### Context
|
|
235
|
+
When having a single select option list displayed horizontally, `RadioBar` provides a better user interface and experience.
|
|
236
|
+
|
|
237
|
+
#### Migration steps
|
|
238
|
+
- Replace any instances of `RadioList` that use `direction="row"` with `RadioBar`.
|
|
239
|
+
|
|
240
|
+
### Deprecated `Card`'s `selected` prop
|
|
241
|
+
|
|
242
|
+
#### Change
|
|
243
|
+
`Card`'s `selected` prop has been deprecated and will be removed in the next major version.
|
|
244
|
+
|
|
245
|
+
#### Context
|
|
246
|
+
There was a concept of a `Card` being selected (driven by the `selected` prop) but it failed to meet proper accessibility standards. This was due to the individual `Card` component not having the proper context of how it was being used to correctly apply aria attributes such as `aria-role` and `aria-checked`.
|
|
247
|
+
|
|
248
|
+
#### Migration steps
|
|
249
|
+
- General guidance remains to prefer more purpose specific input components such as `Multiselect`, `RadioList`, or `Switch` over using `Card` in an input context due to the accessibility considerations they contain. If possible consider removing any selectable `Card` usage and migrating to those components instead.
|
|
250
|
+
- If continuing to use `Card` as an input, remove any passing of the `selected` prop to `Card` and provide selected state accessibility affordance instead by using a radio button or checkbox in the `Card` such as in the `Card.Header`. Be sure to handle aria attributes such as [aria-role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles) and [aria-checked](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked) as your use case may require.
|
|
251
|
+
|
|
252
|
+
### Deprecated `Select`'s `appearance="link"` value
|
|
253
|
+
|
|
254
|
+
#### Change
|
|
255
|
+
`Select`'s `appearance="link"` value has been deprecated and will be removed in the next major version.
|
|
256
|
+
|
|
257
|
+
#### Context
|
|
258
|
+
Using a `Select` with `appearance="link"` can be misleading because links are primarily used for navigation, while a `Select` is designed for making a choice, which involves a different interaction model.
|
|
259
|
+
This difference can cause confusion and conflict with accessibility expectations, as dropdowns have different interaction requirements compared to inline links.
|
|
260
|
+
|
|
261
|
+
#### Migration steps
|
|
262
|
+
- Replace Select with appearance="link" by using either appearance="default" or appearance="subtle", depending on design requirements.
|
|
263
|
+
|
|
264
|
+
### Deprecated `TabBar` and `TabLayout`'s `iconPosition` prop
|
|
265
|
+
|
|
266
|
+
#### Change
|
|
267
|
+
`TabBar` and `TabLayouts`'s `iconPosition` prop is deprecated and will be removed in the next major version.
|
|
268
|
+
|
|
269
|
+
#### Context
|
|
270
|
+
`TabBar`'s `iconPosition="above"` value is deprecated because stacking an icon above text creates a vertical layout that’s harder to scan quickly, especially when multiple `Tab`s are present. The added vertical space can make the `TabBar` taller and more visually crowded, reducing the clarity and simplicity that `TabBar`s are supposed to offer.
|
|
271
|
+
Due to this `TabBar`'s `iconPosition` would only have the value of `left` remaining thus there is no longer a need for the `iconPosition` prop to specify icon positioning. Because `TabLayout` uses `TabBar` its matching prop is deprecated as well.
|
|
272
|
+
|
|
273
|
+
#### Migration steps
|
|
274
|
+
- Remove any setting of `TabBar` or `TabLayout`'s `iconPosition` prop and instead allow its default behavior of left icon positioning to take effect when icons are passed.
|
|
275
|
+
|
|
276
|
+
### Deprecated `Multiselect`'s `selectAllAppearance="buttongroup"` value
|
|
277
|
+
|
|
278
|
+
#### Change
|
|
279
|
+
`Multiselect`'s `"buttongroup"` value of the `selectAllAppearance` prop has been deprecated and will be removed in the next major version.
|
|
280
|
+
|
|
281
|
+
#### Context
|
|
282
|
+
Using `Multiselect`'s `selectAllAppearance="checkbox"` will fix accessibility issue by making it easier to toggle between "select all" and "select none" with one less tab stop.
|
|
283
|
+
|
|
284
|
+
#### Migration steps
|
|
285
|
+
- Replace `Mulitselect`'s `selectAllAppearance="buttongroup"` with `selectAllAppearance="checkbox"`.
|
|
286
|
+
|
|
287
|
+
### New implementation for `Markdown`
|
|
288
|
+
|
|
289
|
+
#### Change
|
|
290
|
+
The `commonmark-react-markdown` library has been replaced with `react-markdown` for rendering markdown.
|
|
291
|
+
|
|
292
|
+
#### Context
|
|
293
|
+
`commonmark-react-markdown` does not support GitHub flavored markdown (GFM) and is no longer actively-maintained. `react-markdown` supports GFM via plugins. In addition to other features, this primarily enables rendering tables within markdown.
|
|
294
|
+
|
|
295
|
+
`react-markdown` ships as ESM which can cause issues with test runners like `jest`.
|
|
296
|
+
|
|
297
|
+
#### Migration steps
|
|
298
|
+
- If using `jest`, add the following to your `jest.config` file:
|
|
299
|
+
```
|
|
300
|
+
moduleNameMapper: {
|
|
301
|
+
'react-markdown': '<rootDir>../../node_modules/react-markdown/react-markdown.min.js',
|
|
302
|
+
},
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
### New `Modal.Footer` layout
|
|
307
|
+
|
|
308
|
+
#### Change
|
|
309
|
+
|
|
310
|
+
`Modal.Footer` has a new `layout` prop to control the layout and styling of children.
|
|
311
|
+
|
|
312
|
+
#### Context
|
|
313
|
+
|
|
314
|
+
Common use cases for content within Modal.Footer include:
|
|
315
|
+
- A single Button
|
|
316
|
+
- A pair of Buttons
|
|
317
|
+
- Documentation links
|
|
318
|
+
- Controls (e.g., Checkbox, Switch)
|
|
319
|
+
- Wizards
|
|
320
|
+
- Static content
|
|
321
|
+
- Combinations of the above
|
|
322
|
+
|
|
323
|
+
In 4.x versions, `Modal.Footer` handled styling for a single `Button` or pair of `Button`s correctly. Other use cases required custom styling. In 5.x `Button`'s no longer have margin from sibling `[data-inline]` elements, which would break the use cases previously supported by `Modal.Footer` in 4.x.
|
|
324
|
+
|
|
325
|
+
To simplify the implementation and ensure consistent design for these common use cases, the default styling for `Modal.Footer` has been updated. Now, these common use cases will display correctly without requiring additional styling.
|
|
326
|
+
|
|
327
|
+
A new prop `layout` has been added to `Modal.Footer` to control styling children.
|
|
328
|
+
The default value, `auto`, uses the updated styling, while `layout="none"` will revert to the 4.x styling, in cases where the new layout is incorrect.
|
|
329
|
+
|
|
330
|
+
#### Migration steps
|
|
331
|
+
**For a single Button or pair of Buttons**: No migration is necessary—existing code should work as before.
|
|
332
|
+
|
|
333
|
+
**For other common use cases (e.g., Checkbox, static content, wizards)**: Any custom layout or styling previously applied may no longer be needed and can be removed.
|
|
334
|
+
|
|
335
|
+
**For custom layouts**: If a custom layout is still required, revert to the 4.x styling by setting the `layout="none"` prop and/or refactor styles to work with the `auto` styling.
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
### `Button`, `Clickable', `CollapsiblePanel`, and `Menu.Item`'s default `disabled` behavior is now `dimmed`
|
|
339
|
+
|
|
340
|
+
#### Change
|
|
341
|
+
|
|
342
|
+
`Button`, `Clickable`, `CollapsiblePanel`, and `Menu.Item` components with the `disabled` prop will, by default, exhibit the `dimmed` behavior.
|
|
343
|
+
To revert to the original behavior (where the component cannot receive focus), set disabled="disabled".
|
|
344
|
+
|
|
345
|
+
For testing, a new `data-test-disabled` test hook has been added.
|
|
346
|
+
|
|
347
|
+
#### Context
|
|
348
|
+
|
|
349
|
+
Whenever possible `disabled` components should be avoided.
|
|
350
|
+
|
|
351
|
+
A `disabled="disabled"` component is less accessible, since it is less discoverable to keyboard users by not receiving focus. Additionally, `Tooltip`s associated with these components become inaccessible, since the component cannot receive focus to activate the `Tooltip`.
|
|
352
|
+
|
|
353
|
+
`disabled="dimmed"` was introduced in v4.25.0 to provide a more inclusive approach to disabling components. Dimmed components remain focusable, are semantically marked as disabled, and still prevent the user from activating the component.
|
|
354
|
+
|
|
355
|
+
By using the `"dimmed"` state as the default, the user experience of these components is more inclusive.
|
|
356
|
+
|
|
357
|
+
#### Migration Steps
|
|
358
|
+
|
|
359
|
+
###### Validate new default `dimmed` behavior
|
|
360
|
+
|
|
361
|
+
Validate your application and components work as expected with the new default behavior.
|
|
362
|
+
If the component can benefit from being more discoverable and accessible, leave the `disabled` prop as is.
|
|
363
|
+
|
|
364
|
+
###### Use `disabled="disabled"` sparingly
|
|
365
|
+
Assess whether you want to retain the button’s original disabled behavior (non-focusable, non-interactive, etc.). If that's the case, set disabled="disabled".
|
|
366
|
+
|
|
367
|
+
###### Updating tests
|
|
368
|
+
When testing, it is recommended to test the user interaction rather than component's state or props (e.g. test that the user cannot activate the control).
|
|
369
|
+
|
|
370
|
+
Matchers like `toBeDisabled()` will no longer pass when using `disabled` or `disabled="dimmed"`.
|
|
371
|
+
If it is necessary to test the components state, use the new test hook state attribute.
|
|
372
|
+
|
|
373
|
+
* For `dimmed` components, replace `expect(button).toBeDisabled()` with:
|
|
374
|
+
```
|
|
375
|
+
expect(button).toHaveAttribute('data-test-disabled');
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
* For `disabled="disabled" components, `toBeDisabled` will continue to work.
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
### `Slider`'s test hook `[data-test="handle"]` renamed to `[data-test="thumb"]`
|
|
382
|
+
|
|
383
|
+
#### Change
|
|
384
|
+
|
|
385
|
+
`Slider`'s test hook `[data-test="handle"]` has been renamed to `[data-test="thumb"]`.
|
|
386
|
+
|
|
387
|
+
#### Context
|
|
388
|
+
|
|
389
|
+
`Slider`'s draggable control has been renamed from "handle" to "thumb" to better align with
|
|
390
|
+
the more commonly used name for this element (e.g. ARIA refers to it as "thumb"). Also,
|
|
391
|
+
the name "handle" can be misleading, as it could be confused with event handlers, etc.
|
|
392
|
+
|
|
393
|
+
#### Migration steps
|
|
394
|
+
|
|
395
|
+
Replace all usage of `Slider`'s test hook `[data-test="handle"]` with `[data-test="thumb"]`.
|
|
396
|
+
|
|
397
|
+
### `Dropdown`'s `toggle` prop now requires an HTML Element or `React.forwardRef`
|
|
398
|
+
|
|
399
|
+
#### Change
|
|
400
|
+
|
|
401
|
+
`Dropdown`'s `toggle` prop no longer accepts React class components or functional components without `React.forwardRef`.
|
|
402
|
+
Components passed to `Dropdown`'s `toggle` prop must accept a `ref` that returns an HTML element.
|
|
403
|
+
|
|
404
|
+
#### Context
|
|
405
|
+
|
|
406
|
+
`Dropdown` previously leveraged `Popover`s usage of `findDOMNode` to find the underlying HTML element for a React component.
|
|
407
|
+
Given that `findDOMNode` is deprecated and scheduled for removal in React 19, we're removing our usages of it.
|
|
408
|
+
|
|
409
|
+
#### Migration Steps
|
|
410
|
+
|
|
411
|
+
If you are using `Button`, `Clickable`, or `Link` components as the `toggle`, no migration is necessary.
|
|
412
|
+
|
|
413
|
+
Otherwise:
|
|
414
|
+
- Convert any components passed to `toggle` to `React.forwardRef` components that forward the ref to an HTML element.
|
|
415
|
+
- If you previously passed a component wrapped in `Tooltip` to `toggle`, you need to forward the ref to the wrapped component.
|
|
416
|
+
- Consider using `react-ui`'s `Button`, `Clickable`, or `Link` components for the `toggle` prop.
|
|
417
|
+
- See the React docs for alternatives to `findDOMNode` usage: https://18.react.dev/reference/react-dom/findDOMNode#alternatives
|
|
418
|
+
|
|
419
|
+
### `Popover`'s `anchor` prop now requires an HTML element
|
|
420
|
+
|
|
421
|
+
#### Change
|
|
422
|
+
|
|
423
|
+
`Popover`'s `anchor` prop now requires a ref to a HTML element and no longer accepts refs to React class component instances.
|
|
424
|
+
|
|
425
|
+
#### Context
|
|
426
|
+
|
|
427
|
+
`Popover`s has previously used `findDOMNode` to find the underlying HTML element for a React component.
|
|
428
|
+
Given that `findDOMNode` is deprecated and scheduled for removal in React 19, we're removing our usages of it.
|
|
429
|
+
|
|
430
|
+
#### Migration Steps
|
|
431
|
+
|
|
432
|
+
Pass a `ref` that refers to an HTML Element to the `anchor` prop.
|
|
433
|
+
|
|
434
|
+
- For `react-ui` components, use `elementRef` to get a `ref` to the underlying HTML element.
|
|
435
|
+
- For custom components, use `forwardRef`.
|
|
436
|
+
- See the React docs for alternatives to `findDOMNode` usage: https://18.react.dev/reference/react-dom/findDOMNode#alternatives
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
### `Switch`'s test hook `[data-test="button"]` renamed to `[data-test="toggle"]`
|
|
440
|
+
|
|
441
|
+
#### Change
|
|
442
|
+
|
|
443
|
+
`Switch`'s test hook `[data-test="button"]` has been renamed to `[data-test="toggle"]`.
|
|
444
|
+
|
|
445
|
+
#### Context
|
|
446
|
+
|
|
447
|
+
`Switch`'s underlying toggle element has been renamed from "button" to "toggle" to be less generic and describe its function of switching between states.
|
|
448
|
+
|
|
449
|
+
#### Migration steps
|
|
450
|
+
|
|
451
|
+
Replace all usage of `Switch`'s test hook `[data-test="button"]` with `[data-test="toggle"]`.
|
|
452
|
+
|
|
453
|
+
### `TabBar`'s `tabWidth` prop has been removed
|
|
454
|
+
|
|
455
|
+
#### Change
|
|
456
|
+
`TabBar`'s `tabWidth` prop has been removed. A new `maxTabWidth` prop has been added to support some use cases previously supported by the `tabWidth` prop.
|
|
457
|
+
|
|
458
|
+
#### Context
|
|
459
|
+
In previous versions `TabBar.Tab`s could have their width statically set by passing the `tabWidth` prop to the `TabBar`. However, the updated design for `TabBar` has responsive widths for `TabBar.Tab`s so setting a static tab width is no longer supported.
|
|
460
|
+
|
|
461
|
+
#### Migration steps
|
|
462
|
+
There are were two possible use cases for `tabWidth`:
|
|
463
|
+
|
|
464
|
+
1) If you desire each `Tab` to not exceed a certain width, use `maxTabWidth`.
|
|
465
|
+
2) If you desire each `Tab` to be the exact same width, we recommend against this - please reach out to us if you have a specific use case in mind.
|
|
466
|
+
|
|
467
|
+
### Deprecated `Card.Header`'s `anchor` prop
|
|
468
|
+
|
|
469
|
+
#### Change
|
|
470
|
+
|
|
471
|
+
`Card.Header`'s `anchor` prop has been deprecated and will be removed in the next major version.
|
|
472
|
+
|
|
473
|
+
#### Context
|
|
474
|
+
|
|
475
|
+
Card titles need to be headings when there is content underneath to satisfy accessibility requirement WCAG 1.3.1.
|
|
476
|
+
The recommended way to do this is to pass the `Heading` component into the `title` prop.
|
|
477
|
+
|
|
478
|
+
The anchor prop leads to visual issues when non-text content (such as a Heading is passed to the `title` attribute).
|
|
479
|
+
To avoid this and because the functionality of the `anchor` prop can be achieved by passing the `Anchor` component to the `title` prop,
|
|
480
|
+
we have deprecated the `anchor` prop.
|
|
481
|
+
|
|
482
|
+
#### Migration steps
|
|
483
|
+
Replace all usage of the `anchor` prop with passing in the `Anchor` component to the `title` prop:
|
|
484
|
+
```jsx
|
|
485
|
+
<Card.Header title={<Anchor name="Title">Title</Anchor>} />
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Deprecated `Popover`'s `"inverted"` value of the `appearance` prop
|
|
489
|
+
|
|
490
|
+
#### Change
|
|
491
|
+
|
|
492
|
+
`Popover`'s `"inverted"` value of the `appearance` prop has been deprecated and will be removed in the next major version.
|
|
493
|
+
|
|
494
|
+
#### Context
|
|
495
|
+
|
|
496
|
+
The inverted appearance was deprecated to ensure the Popover background aligns with the color scheme, i.e. Popover should be light in light mode and dark in dark mode.
|
|
497
|
+
|
|
498
|
+
#### Migration steps
|
|
499
|
+
Replace all usage of Popover's `appearance="inverted"` with `appearance="normal"` (default).
|
|
500
|
+
If teams need to keep inverted Popovers they can use `backgroundColorFloating` and `contentColorInverted`. Otherwise Popover uses `backgroundColorPopup`.
|
|
501
|
+
```jsx
|
|
502
|
+
const StyledContent = styled.div`
|
|
503
|
+
background-color: ${variables.backgroundColorFloating};
|
|
504
|
+
color: ${variables.contentColorInverted};
|
|
505
|
+
`;
|
|
506
|
+
|
|
507
|
+
return (
|
|
508
|
+
<Popover>
|
|
509
|
+
<StyledContent>Popover content</StyledContent>
|
|
510
|
+
</Popover>
|
|
511
|
+
)
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
### `Button`'s `label` prop no longer sets `label` attribute
|
|
515
|
+
|
|
516
|
+
#### Change
|
|
517
|
+
`Button`'s `label` prop no longer sets HTML attribute `label` on the underlying button element.
|
|
518
|
+
|
|
519
|
+
#### Context
|
|
520
|
+
In previous versions, the `label` prop, which sets the text on the Button, was also passed as a `label` HTML attribute which is invalid HTML for a `<button>`. This has been removed.
|
|
521
|
+
|
|
522
|
+
#### Migration steps
|
|
523
|
+
Replace usages of `label` selector in tests with a different suitable query e.g. replace `querySelector('[label="Save"]')` with `getByText('Save')`.
|
|
524
|
+
|
|
525
|
+
### `Color`'s test hook `[data-test="color"]` moved to root and `[data-test="toggle-swatch"]` added to toggle swatch
|
|
526
|
+
|
|
527
|
+
#### Change
|
|
528
|
+
|
|
529
|
+
`Color`'s test hook `[data-test="color"]` has been moved to the root `div` element and a new test hook `[data-test="toggle-swatch"]` has been added to the toggle swatch.
|
|
530
|
+
|
|
531
|
+
#### Context
|
|
532
|
+
|
|
533
|
+
`Color`'s test hook `[data-test="color"]` was incorrectly documented as the root of the component but was actually set on the toggle swatch.
|
|
534
|
+
|
|
535
|
+
#### Migration steps
|
|
536
|
+
If the test hook needs to be on the root element of `Color`, use `[data-test="color"]`.
|
|
537
|
+
If the test hook was being used to interact with the toggle swatch, replace usage of `[data-test="color"]` with `[data-test="toggle-swatch"]`.
|
|
538
|
+
|
|
539
|
+
### All components that previously used `KeyboardEvent`'s deprecated `keyCode` property now use `KeyboardEvent`'s `key` property.
|
|
540
|
+
|
|
541
|
+
#### Change
|
|
542
|
+
|
|
543
|
+
Switched all components that previously used `KeyboardEvent`'s deprecated `keyCode` property to use its `key` property instead.
|
|
544
|
+
|
|
545
|
+
#### Context
|
|
546
|
+
|
|
547
|
+
Since current testing library tooling (such as `userEvent`) no longer provides a keyCode along with synthetic keyboard events,
|
|
548
|
+
upgrading testing libaries could cause tests to break. By removing the usage of `keyCode` in our codebase, this enables testing libary upgrades.
|
|
549
|
+
|
|
550
|
+
#### Migration steps
|
|
551
|
+
|
|
552
|
+
Use `KeyboardEvent`'s `key` property instead `keyCode` property to identify key presses.
|
|
553
|
+
|
|
5
554
|
## 4.44.0
|
|
6
555
|
|
|
7
556
|
### `ButtonGroup` role changed to `group`
|
|
8
557
|
|
|
9
|
-
|
|
558
|
+
#### Change
|
|
10
559
|
|
|
11
560
|
`ButtonGroup`'s `role` has changed from `menubar` to `group`.
|
|
12
561
|
Child `Button`'s `role`s have changed from `menuitem` to `button`.
|