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

Don't scroll lock when transition isn't showing #2422

Merged
merged 3 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add tests
  • Loading branch information
thecrypticace committed Apr 10, 2023
commit a508c2643c9413f3b65ba684e2f7ed1a45870293
22 changes: 22 additions & 0 deletions packages/@headlessui-react/src/components/dialog/dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,28 @@ describe('Rendering', () => {
expect(document.documentElement.style.overflow).toBe('')
})
)

it(
'should not have a scroll lock when the transition marked as not shown',
suppressConsoleLogs(async () => {
function Example() {
return (
<Transition as={Fragment} show={false} unmount={false}>
<Dialog as="div" onClose={() => {}}>
<input type="text" />
</Dialog>
</Transition>
)
}

render(<Example />)

await nextFrame()

// The overflow should NOT be there
expect(document.documentElement.style.overflow).toBe('')
})
)
})

describe('Dialog.Overlay', () => {
Expand Down
24 changes: 24 additions & 0 deletions packages/@headlessui-vue/src/components/dialog/dialog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,30 @@ describe('Rendering', () => {
expect(document.documentElement.style.overflow).toBe('')
})
)

it(
'should not have a scroll lock when the transition marked as not shown',
suppressConsoleLogs(async () => {
renderTemplate({
components: {
Dialog,
TransitionRoot,
},
template: `
<TransitionRoot as="template" :show="false" :unmount="false">
<Dialog as="div">
<input type="text" />
</Dialog>
</TransitionRoot>
`,
})

await nextFrame()

// The overflow should NOT be there
expect(document.documentElement.style.overflow).toBe('')
})
)
})

describe('DialogOverlay', () => {
Expand Down