-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[🚑️][Dialog]: Hotfix an issue that caused the focus trap to not work …
…properly (#90)
- Loading branch information
Showing
6 changed files
with
74 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const getScrollingState = (element: HTMLElement) => { | ||
const isScrollable = (node: HTMLElement) => { | ||
const overflow = getComputedStyle(node).getPropertyValue("overflow"); | ||
|
||
return overflow.includes("auto") || overflow.includes("scroll"); | ||
}; | ||
|
||
const getScrollParent = (element: HTMLElement) => { | ||
let current = element.parentNode as HTMLElement | null; | ||
|
||
while (current) { | ||
if (!(element instanceof HTMLElement)) break; | ||
if (!(element instanceof SVGElement)) break; | ||
|
||
if (isScrollable(current)) return current; | ||
|
||
current = current.parentNode as HTMLElement | null; | ||
} | ||
|
||
return document.scrollingElement || document.documentElement; | ||
}; | ||
|
||
const scrollParent = getScrollParent(element); | ||
|
||
return { | ||
vertical: scrollParent.scrollHeight > scrollParent.clientHeight, | ||
horizontal: scrollParent.scrollWidth > scrollParent.clientWidth, | ||
}; | ||
}; | ||
|
||
export default getScrollingState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@styleless-ui/react", | ||
"version": "1.0.0-rc.1", | ||
"version": "1.0.0-rc.2", | ||
"description": "Completely unstyled, headless and accessible React UI components.", | ||
"author": "mimshins <[email protected]>", | ||
"license": "MIT", | ||
|