@mittwald/flow-react-components 1.2.0-next.58 → 1.2.0-next.59
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/MIGRATION.md +85 -0
- package/dist/assets/component-index.json +1 -1
- package/dist/assets/doc-properties.json +1 -1
- package/dist/js/packages/components/src/components/Popover/Popover.mjs +18 -7
- package/dist/js/packages/components/src/components/Popover/Popover.mjs.map +1 -1
- package/dist/js/packages/components/src/lib/controller/overlay/OverlayController.mjs +24 -1
- package/dist/js/packages/components/src/lib/controller/overlay/OverlayController.mjs.map +1 -1
- package/dist/types/components/Popover/Popover.d.ts +19 -0
- package/dist/types/lib/controller/overlay/OverlayController.d.ts +13 -0
- package/package.json +9 -9
package/MIGRATION.md
CHANGED
|
@@ -28,6 +28,91 @@ The CLI's own output does detect it and prints the right form.
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
+
<a id="popover-open-state-props"></a>
|
|
32
|
+
|
|
33
|
+
## Popover: `defaultOpen` renamed, `isOpen` and `onOpenChange` now work
|
|
34
|
+
|
|
35
|
+
**Since `1.1.47`** · migration · codemod available · also applies to
|
|
36
|
+
`@mittwald/flow-remote-react-components`
|
|
37
|
+
|
|
38
|
+
`Popover`'s open state props now behave the way their names say. This covers
|
|
39
|
+
`ContextualHelp` and `ContextMenu` too, which inherit them.
|
|
40
|
+
|
|
41
|
+
#### `defaultOpen` is now `isDefaultOpen`
|
|
42
|
+
|
|
43
|
+
The name matches `Modal` and the other overlays.
|
|
44
|
+
|
|
45
|
+
```diff
|
|
46
|
+
- <ContextualHelp defaultOpen>
|
|
47
|
+
+ <ContextualHelp isDefaultOpen>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`defaultOpen` keeps working and logs a deprecation warning. A codemod renames
|
|
51
|
+
it, on `Popover`, `ContextualHelp` and `ContextMenu` only — the identically
|
|
52
|
+
named react-aria prop on `Select`, `MenuTrigger`, `Tooltip`, `TooltipTrigger`,
|
|
53
|
+
`DialogTrigger`, `DatePicker` and `DateRangePicker` is untouched.
|
|
54
|
+
|
|
55
|
+
#### `onOpenChange` reports instead of taking over
|
|
56
|
+
|
|
57
|
+
Passing `onOpenChange` used to switch the popover into a controlled mode that
|
|
58
|
+
had no `isOpen` to control it with: the handler fired, and the popover stopped
|
|
59
|
+
closing. It is now a notification that fires on every path — react-aria's
|
|
60
|
+
dismissal, and a close performed through the controller — and never performs or
|
|
61
|
+
suppresses the change.
|
|
62
|
+
|
|
63
|
+
```diff
|
|
64
|
+
- <Popover onOpenChange={(isOpen) => controller.setOpen(isOpen)}>
|
|
65
|
+
+ <Popover onOpenChange={(isOpen) => track(isOpen)}>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Two things to check:
|
|
69
|
+
|
|
70
|
+
- A handler that performed the close itself can drop that call. Leaving it in is
|
|
71
|
+
harmless — the controller ignores a state it is already applying.
|
|
72
|
+
- A handler that relied on the prop to _block_ a close no longer blocks it. Use
|
|
73
|
+
the controller for that: a handler registered through `useOverlayController`'s
|
|
74
|
+
`onClose` still aborts by returning `false`.
|
|
75
|
+
|
|
76
|
+
#### `isOpen` controls the popover
|
|
77
|
+
|
|
78
|
+
`isOpen` was inherited from react-aria but silently overridden. It is now the
|
|
79
|
+
open state whenever it is set.
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
83
|
+
|
|
84
|
+
<Popover isOpen={isOpen} onOpenChange={setIsOpen}>
|
|
85
|
+
…
|
|
86
|
+
</Popover>;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
If you pass `isOpen` without updating it from `onOpenChange` — for instance by
|
|
90
|
+
spreading props that happen to carry it — the popover no longer opens. Drop the
|
|
91
|
+
prop, or wire up the state.
|
|
92
|
+
|
|
93
|
+
A controller stays the third option and needs neither prop: with
|
|
94
|
+
`controller={controller}`, `onOpenChange` is a pure monitor.
|
|
95
|
+
|
|
96
|
+
**Apply:** Rename `defaultOpen` to `isDefaultOpen` on `Popover`,
|
|
97
|
+
`ContextualHelp` and `ContextMenu` — a codemod does it, scoped to those three.
|
|
98
|
+
Leave `defaultOpen` alone on `Select`, `MenuTrigger`, `Tooltip`,
|
|
99
|
+
`TooltipTrigger`, `DialogTrigger`, `DatePicker` and `DateRangePicker`, where it
|
|
100
|
+
is react-aria's own prop and unchanged. Then check every `isOpen` and
|
|
101
|
+
`onOpenChange` passed to those three by hand, because both changed behaviour and
|
|
102
|
+
neither is mechanically decidable. `isOpen` used to be ignored and now controls
|
|
103
|
+
the popover: a value that is not kept up to date through `onOpenChange` keeps
|
|
104
|
+
the popover closed. `onOpenChange` used to take over the open state and now only
|
|
105
|
+
reports it, so a handler that performed the close itself —
|
|
106
|
+
`onOpenChange={(open) => controller.setOpen(open)}` — can drop that call, and a
|
|
107
|
+
handler that relied on the prop to _suppress_ the close no longer does; use the
|
|
108
|
+
controller's `onClose` for that.
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
npx @mittwald/flow-codemods@latest popover-open-state-props src
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
31
116
|
<a id="tabler-icons-no-longer-transitive"></a>
|
|
32
117
|
|
|
33
118
|
## @tabler/icons-react is no longer installed alongside Flow
|