-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delay focus until MCE init (squashed 11 commits)
- Loading branch information
Showing
7 changed files
with
88 additions
and
28 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
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,24 @@ | ||
/** | ||
* Given a DOM node, finds the closest scrollable container node. | ||
* | ||
* @param {Element} node Node from which to start. | ||
* | ||
* @return {?Element} Scrollable container node, if found. | ||
*/ | ||
export function getScrollContainer( node ) { | ||
if ( ! node || node === document.body ) { | ||
return window; | ||
} | ||
|
||
// Scrollable if scrollable height exceeds displayed... | ||
if ( node.scrollHeight > node.clientHeight ) { | ||
// ...except when overflow is defined to be hidden or visible | ||
const { overflowY } = window.getComputedStyle( node ); | ||
if ( /(auto|scroll)/.test( overflowY ) ) { | ||
return node; | ||
} | ||
} | ||
|
||
// Continue traversing | ||
return getScrollContainer( node.parentNode ); | ||
} |
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