Skip to content

Commit c4e35f3

Browse files
authored
Fix closing of Popover.Panel in React 18 (#1409)
* remove unnecessary `SetPanel` action * update changelog
1 parent 6667fac commit c4e35f3

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
## [Unreleased - @headlessui/react]
1515

16-
- Nothing yet!
16+
### Fixed
17+
18+
- Fix closing of `Popover.Panel` in React 18 ([#1409](https://github.com/tailwindlabs/headlessui/pull/1409))
1719

1820
## [@headlessui/react@1.6.1] - 2022-05-03
1921

packages/@headlessui-react/src/components/popover/popover.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,6 @@ let Panel = forwardRefWithAs(function Panel<TTag extends ElementType = typeof DE
640640
[state, internalPanelRef, dispatch]
641641
)
642642

643-
// Unlink on "unmount" myself
644-
useEffect(() => () => dispatch({ type: ActionTypes.SetPanel, panel: null }), [dispatch])
645-
646643
// Unlink on "unmount" children
647644
useEffect(() => {
648645
if (props.static) return

packages/@headlessui-vue/src/components/popover/popover.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import {
2+
computed,
23
defineComponent,
34
inject,
4-
onUnmounted,
55
provide,
66
ref,
77
watchEffect,
88

99
// Types
1010
InjectionKey,
1111
Ref,
12-
computed,
1312
} from 'vue'
1413

1514
import { match } from '../../utils/match'
@@ -477,10 +476,6 @@ export let PopoverPanel = defineComponent({
477476

478477
provide(PopoverPanelContext, api.panelId)
479478

480-
onUnmounted(() => {
481-
api.panel.value = null
482-
})
483-
484479
// Move focus within panel
485480
watchEffect(() => {
486481
if (!focus) return

0 commit comments

Comments
 (0)