File tree Expand file tree Collapse file tree 4 files changed +49
-2
lines changed
@headlessui-react/src/components/dialog Expand file tree Collapse file tree 4 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -440,6 +440,28 @@ describe('Rendering', () => {
440
440
expect ( document . documentElement . style . overflow ) . toBe ( '' )
441
441
} )
442
442
)
443
+
444
+ it (
445
+ 'should not have a scroll lock when the transition marked as not shown' ,
446
+ suppressConsoleLogs ( async ( ) => {
447
+ function Example ( ) {
448
+ return (
449
+ < Transition as = { Fragment } show = { false } unmount = { false } >
450
+ < Dialog as = "div" onClose = { ( ) => { } } >
451
+ < input type = "text" />
452
+ </ Dialog >
453
+ </ Transition >
454
+ )
455
+ }
456
+
457
+ render ( < Example /> )
458
+
459
+ await nextFrame ( )
460
+
461
+ // The overflow should NOT be there
462
+ expect ( document . documentElement . style . overflow ) . toBe ( '' )
463
+ } )
464
+ )
443
465
} )
444
466
445
467
describe ( 'Dialog.Overlay' , ( ) => {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
12
- Fix focus styles showing up when using the mouse ([ #2347 ] ( https://github.com/tailwindlabs/headlessui/pull/2347 ) )
13
13
- Disable ` ComboboxInput ` when its ` Combobox ` is disabled ([ #2375 ] ( https://github.com/tailwindlabs/headlessui/pull/2375 ) )
14
14
- Add ` FocusTrap ` event listeners once document has loaded ([ #2389 ] ( https://github.com/tailwindlabs/headlessui/pull/2389 ) )
15
+ - Don't scroll-lock ` <Dialog> ` when wrapping transition isn't showing ([ #2422 ] ( https://github.com/tailwindlabs/headlessui/pull/2422 ) )
15
16
16
17
### Added
17
18
Original file line number Diff line number Diff line change @@ -615,6 +615,30 @@ describe('Rendering', () => {
615
615
expect ( document . documentElement . style . overflow ) . toBe ( '' )
616
616
} )
617
617
)
618
+
619
+ it (
620
+ 'should not have a scroll lock when the transition marked as not shown' ,
621
+ suppressConsoleLogs ( async ( ) => {
622
+ renderTemplate ( {
623
+ components : {
624
+ Dialog,
625
+ TransitionRoot,
626
+ } ,
627
+ template : `
628
+ <TransitionRoot as="template" :show="false" :unmount="false">
629
+ <Dialog as="div">
630
+ <input type="text" />
631
+ </Dialog>
632
+ </TransitionRoot>
633
+ ` ,
634
+ } )
635
+
636
+ await nextFrame ( )
637
+
638
+ // The overflow should NOT be there
639
+ expect ( document . documentElement . style . overflow ) . toBe ( '' )
640
+ } )
641
+ )
618
642
} )
619
643
620
644
describe ( 'DialogOverlay' , ( ) => {
Original file line number Diff line number Diff line change @@ -193,14 +193,14 @@ export let TransitionChild = defineComponent({
193
193
}
194
194
195
195
let container = ref < HTMLElement | null > ( null )
196
- let state = ref ( TreeStates . Visible )
197
196
let strategy = computed ( ( ) => ( props . unmount ? RenderStrategy . Unmount : RenderStrategy . Hidden ) )
198
197
199
198
expose ( { el : container , $el : container } )
200
199
201
200
let { show, appear } = useTransitionContext ( )
202
201
let { register, unregister } = useParentNesting ( )
203
202
203
+ let state = ref ( show . value ? TreeStates . Visible : TreeStates . Hidden )
204
204
let initial = { value : true }
205
205
206
206
let id = useId ( )
@@ -228,7 +228,7 @@ export let TransitionChild = defineComponent({
228
228
if ( ! id ) return
229
229
230
230
// Make sure that we are visible
231
- if ( show && state . value !== TreeStates . Visible ) {
231
+ if ( show . value && state . value !== TreeStates . Visible ) {
232
232
state . value = TreeStates . Visible
233
233
return
234
234
}
You can’t perform that action at this time.
0 commit comments