Skip to content
Merged
Changes from all commits
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
10 changes: 7 additions & 3 deletions src/hooks/useScrollLock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ class ModernScrollLock {

otherProperties.forEach(prop => {
if (!this.externalTracker.externallyModified.has(prop)) {
const originalValue = this.externalTracker.originalStyles![prop]
const originalInlineValue = this.originalStyles[prop]

// If original value was from computed styles (not inline), remove the inline property
if (this.originalStyles[prop] === '') {
// If we didn't have an inline style originally, remove the property entirely
if (originalInlineValue === '') {
body.style.removeProperty(prop === 'paddingRight' ? 'padding-right' : prop)
} else {
// Restore the original inline value with type safety
const originalValue = this.externalTracker.originalStyles![prop]
if (prop === 'paddingRight') {
body.style.paddingRight = originalValue
} else if (prop === 'position') {
Expand All @@ -153,6 +154,9 @@ class ModernScrollLock {
body.style.width = originalValue
}
}
} else {
// If externally modified, remove our inline styles to let external changes take effect
body.style.removeProperty(prop === 'paddingRight' ? 'padding-right' : prop)
}
})

Expand Down