Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Sebsatian review
  • Loading branch information
oliviertassinari committed Apr 19, 2020
commit 3b6195de9ab0243fc7760cd0c1dc9a763dd62fa5
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ By default, the component responds to the trailing events (click + touch end).
However, you can configure it to respond to the leading events (mouse down + touch start).

{{"demo": "pages/components/click-away-listener/LeadingClickAway.js"}}

> ⚠️ In this mode, only interactions on the scrollbar of the document is ignored.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function mapEventPropToEvent(eventProp) {
return eventProp.substring(2).toLowerCase();
}

function hasClickedScrollbar(event) {
function clickedRootScrollbar(event) {
return (
document.documentElement.clientWidth < event.clientX ||
document.documentElement.clientHeight < event.clientY
Expand Down Expand Up @@ -63,7 +63,7 @@ function ClickAwayListener(props) {
// 1. IE 11 support, which trigger the handleClickAway even after the unbind
// 2. The child might render null.
// 3. Behave like a blur listener.
if (!mountedRef.current || !nodeRef.current || hasClickedScrollbar(event)) {
if (!mountedRef.current || !nodeRef.current || clickedRootScrollbar(event)) {
return;
}

Expand Down