-
-
Notifications
You must be signed in to change notification settings - Fork 678
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
Only consider document scrollable if not prevented #1081
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@dnd-kit/core': patch | ||
--- | ||
|
||
Avoid considering `document` as scrollable if `overflow: hidden` is present. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {getWindow} from '@dnd-kit/utilities'; | ||
|
||
import {hasOverflowStyles} from './hasOverflowStyles'; | ||
|
||
export function isScrollingDisabled( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created this dedicated function because using a single
Combining both into |
||
element: Element, | ||
computedStyle: CSSStyleDeclaration = getWindow(element).getComputedStyle( | ||
element | ||
) | ||
): boolean { | ||
return hasOverflowStyles(element, computedStyle, /(hidden)/); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {getWindow} from '@dnd-kit/utilities'; | ||
import {hasOverflowStyles} from './hasOverflowStyles'; | ||
|
||
export function isScrollingEnabled( | ||
element: Element, | ||
computedStyle: CSSStyleDeclaration = getWindow(element).getComputedStyle( | ||
element | ||
) | ||
): boolean { | ||
return hasOverflowStyles(element, computedStyle, /(auto|scroll|overlay)/); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTMLElement
is a subset ofElement
, soElement
should be fine to use here (it won't break the public API).Broadening the type was needed to accept
node.scrollableElement
ingetScrollableAncestors.ts
, which is of typeElement
and notHTMLElement
. However they both are processed byhasOverflowStyles
just fine, becausegetComputedStyle
accepts both.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: it's a breaking change if somebody uses this function's type in contra-variant position like
const fn: (hasOverflowStyles: typeof hasOverflowStyles) => void
and thenfn(myCustomHasOverflowStyles)
but it's a stretch.