Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure panels re-register when IDs are calculated in React < 18 #2883

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/@headlessui-react/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `immediate` prop to `<Combobox />` for immediately opening the Combobox when the `input` receives focus ([#2686](https://github.com/tailwindlabs/headlessui/pull/2686))
- Add `virtual` prop to `Combobox` component ([#2779](https://github.com/tailwindlabs/headlessui/pull/2779))

### Fixed

- Make sure panels re-register when IDs are calculated in React < 18 ([#2883](https://github.com/tailwindlabs/headlessui/pull/2883))

## [1.7.18] - 2024-01-08

### Fixed
Expand Down
12 changes: 11 additions & 1 deletion packages/@headlessui-react/src/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,17 @@ function PanelFn<TTag extends ElementType = typeof DEFAULT_PANEL_TAG>(
let internalPanelRef = useRef<HTMLElement | null>(null)
let panelRef = useSyncRefs(internalPanelRef, ref)

useIsoMorphicEffect(() => actions.registerPanel(internalPanelRef), [actions, internalPanelRef])
useIsoMorphicEffect(
() => actions.registerPanel(internalPanelRef),
[
actions,
internalPanelRef,

// The `id` prop is here to force a re-render of the
// corresponding `Tab` whenever the `id` is calculated in React < 18
id,
]
)

let mySSRIndex = useStableCollectionIndex('panels')

Expand Down