|
1 | 1 | # Manual fixes after the codemod |
2 | 2 |
|
3 | | -## Known gaps to handle explicitly |
| 3 | +## Icons and illustrations |
4 | 4 |
|
5 | | -- `@react-spectrum/toast` imports are not automatically migrated. Move them to S2, then re-check `ToastContainer` mounts and `ToastQueue` usages. |
6 | | -- v3 `Provider` and `defaultTheme` wrappers in apps and tests need human review. S2 does not use the v3 theme object model. |
| 5 | +- If the codemod leaves `TODO(S2-upgrade)` next to an icon or illustration import, pick the nearest S2 replacement manually. |
7 | 6 |
|
8 | | -## Imports and packages |
| 7 | +## Layout components |
9 | 8 |
|
10 | | -- Collapse v3 component imports onto `@react-spectrum/s2`. |
11 | | -- Keep using `@spectrum-icons/*` only when there is no S2 icon or illustration equivalent. Prefer `@react-spectrum/s2/icons/*` and `@react-spectrum/s2/illustrations` when possible. |
12 | | -- If the codemod leaves `TODO(S2-upgrade)` next to an icon or illustration import, pick the nearest S2 replacement manually. |
| 9 | +`Flex`, `Grid`, `View`, and `Well` are not part of S2. These should be updated to `div` elements styled with the macro. |
| 10 | + |
| 11 | +### Flex example |
| 12 | + |
| 13 | +Before: |
| 14 | + |
| 15 | +```jsx |
| 16 | +<Flex direction="column"> |
| 17 | + <div>Item 1</div> |
| 18 | + <div>Item 2</div> |
| 19 | + <div>Item 3</div> |
| 20 | +</Flex> |
| 21 | +``` |
| 22 | + |
| 23 | +After: |
| 24 | + |
| 25 | +```jsx |
| 26 | +<div className={style({display: 'flex', flexDirection: 'column'})}> |
| 27 | + <div>Item 1</div> |
| 28 | + <div>Item 2</div> |
| 29 | + <div>Item 3</div> |
| 30 | +</div> |
| 31 | +``` |
| 32 | + |
| 33 | +### Grid example |
| 34 | + |
| 35 | +Before: |
| 36 | + |
| 37 | +```jsx |
| 38 | +<Grid justifyContent="center"> |
| 39 | + <div>Item 1</div> |
| 40 | + <div>Item 2</div> |
| 41 | + <div>Item 3</div> |
| 42 | +</Grid> |
| 43 | +``` |
| 44 | + |
| 45 | +After: |
13 | 46 |
|
14 | | -## App and Provider setup |
| 47 | +```jsx |
| 48 | +<div className={style({display: 'grid', justifyContent: 'center'})}> |
| 49 | + <div>Item 1</div> |
| 50 | + <div>Item 2</div> |
| 51 | + <div>Item 3</div> |
| 52 | +</div> |
| 53 | +``` |
15 | 54 |
|
16 | | -- Full-page apps usually add `import '@react-spectrum/s2/page.css';` at the entrypoint and no longer need a mandatory root Provider just to supply `theme={defaultTheme}`. |
17 | | -- Embedded sections still use S2 `Provider` with an explicit `background`. |
18 | | -- Keep or add S2 `Provider` only when locale, router integration, color-scheme/background overrides, or SSR `elementType="html"` behavior are needed. |
19 | | -- Preserve unrelated wrappers such as routing, store, analytics, i18n, and host-framework providers. Replace or remove only the React Spectrum-specific layer. |
| 55 | +### View example |
20 | 56 |
|
21 | | -## Style and layout follow-ups |
| 57 | +Before: |
22 | 58 |
|
23 | | -- Convert v3 style props and `UNSAFE_style` cases to the S2 style macro when possible. |
24 | | -- `Flex` and `Grid` often become `div` elements styled with the macro. |
25 | | -- Review `ClearSlots` and other direct `@react-spectrum/utils` imports manually. These are not part of the common S2 app surface. |
| 59 | +```jsx |
| 60 | +<View> |
| 61 | + Content |
| 62 | +</View> |
| 63 | +``` |
| 64 | + |
| 65 | +After: |
| 66 | + |
| 67 | +```jsx |
| 68 | +<div> |
| 69 | + Content |
| 70 | +</div> |
| 71 | +``` |
| 72 | +### Well example |
| 73 | + |
| 74 | +Before: |
| 75 | + |
| 76 | +```jsx |
| 77 | +<Well> |
| 78 | + Content |
| 79 | +</Well> |
| 80 | +``` |
| 81 | + |
| 82 | +After: |
| 83 | + |
| 84 | +```jsx |
| 85 | +<div className={style({ |
| 86 | + display: 'block', |
| 87 | + textAlign: 'start', |
| 88 | + padding: 16, |
| 89 | + minWidth: 160, |
| 90 | + marginTop: 4, |
| 91 | + borderWidth: 1, |
| 92 | + borderRadius: 'sm', |
| 93 | + borderStyle: 'solid', |
| 94 | + borderColor: 'transparent-black-75', |
| 95 | + font: 'body-sm' |
| 96 | +})}> |
| 97 | + Content |
| 98 | +</div> |
| 99 | +``` |
| 100 | + |
| 101 | +## UNSAFE_style and UNSAFE_className |
| 102 | + |
| 103 | +Move `UNSAFE_style` usage to the S2 style macro when possible. |
| 104 | + |
| 105 | +Move `UNSAFE_className` usage to the S2 style macro when possible. |
26 | 106 |
|
27 | 107 | ## Dialogs and collections |
28 | 108 |
|
29 | 109 | - `DialogContainer` and `useDialogContainer` still exist in S2, but the import path changes and dismiss logic may need to move between `Dialog`, `DialogTrigger`, and `DialogContainer`. |
30 | | -- When `Item` survives the codemod, rename it based on its parent: `MenuItem`, `PickerItem`, `ComboBoxItem`, `ListBoxItem`, `Tab`, `TabPanel`, `Tag`, `Breadcrumb`, and similar. |
| 110 | +- When `Item` survives the codemod, rename it based on its parent component: |
| 111 | + |
| 112 | + | Parent component | v3 child | S2 child | |
| 113 | + |---|---|---| |
| 114 | + | Menu / ActionMenu | Item | MenuItem | |
| 115 | + | Picker | Item | PickerItem | |
| 116 | + | ComboBox | Item | ComboBoxItem | |
| 117 | + | ListBox | Item | ListBoxItem | |
| 118 | + | Tabs | Item | Tab / TabPanel | |
| 119 | + | TagGroup | Item | Tag | |
| 120 | + | Breadcrumbs | Item | Breadcrumb | |
| 121 | + |
31 | 122 | - Preserve React `key` when mapping arrays, but ensure collection data items expose `id` when S2 expects it. |
32 | 123 | - Table and ListView migrations often need manual review for row headers, nested columns, and explicit item ids. |
33 | 124 |
|
34 | | -## Tests |
| 125 | +## Toast migration |
35 | 126 |
|
36 | | -- Replace v3 Provider/defaultTheme test wrappers with the minimal S2 `Provider` props the test actually needs, or remove the wrapper entirely if no S2 context is required. |
37 | | -- Update toast mocks and assertions that still reference `@react-spectrum/toast` or old dialog markup. |
| 127 | +- Move `ToastContainer` and `ToastQueue` imports from `@react-spectrum/toast` to `@react-spectrum/s2`. |
| 128 | +- Keep a shared `ToastContainer` mounted near the app root or test harness, then update all queue calls to use the S2 import path. |
| 129 | +- S2 supports `ToastQueue.neutral`, `positive`, `negative`, and `info`. |
| 130 | +- Re-check options such as `timeout`, `actionLabel`, `onAction`, `shouldCloseOnAction`, and `onClose` after the import move. |
| 131 | +- The queue methods still return a close function. Keep programmatic dismissal logic when the existing UX depends on it. |
| 132 | +- Search for every `ToastContainer` mount and every `ToastQueue` usage after moving imports. Shared app roots, secondary entrypoints, and test harnesses are easy to miss. |
0 commit comments