Skip to content

Commit

Permalink
🐛 Changed order in lock() function to adjust padding before changing …
Browse files Browse the repository at this point in the history
…the overflow (#516 from @novacdenis)

* Changed order in lock() function to adjust padding before changing the overflow

* fix test after code changes

---------

Co-authored-by: Julien <juliencaron@protonmail.com>
  • Loading branch information
novacdenis and juliencrn committed Mar 4, 2024
1 parent 6c93665 commit 12c1d94
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/usehooks-ts/src/useScrollLock/useScrollLock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,14 @@ describe('useScrollLock()', () => {
unmount()
expect(document.body.style.overflow).toBe('')
})

it('should add padding-right to prevent width reflow', () => {
const { unmount } = renderHook(() => useScrollLock())

const scrollbarWidth = window.innerWidth - document.body.scrollWidth

expect(document.body.style.paddingRight).toBe(`${scrollbarWidth}px`)
unmount()
expect(document.body.style.paddingRight).toBe('')
})
})

0 comments on commit 12c1d94

Please sign in to comment.