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
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@ function usePopoverScroll( contentRef ) {
const effect = useRefEffect(
( node ) => {
function onWheel( event ) {
const { deltaX, deltaY } = event;
const { deltaX, deltaY, target } = event;
const contentEl = contentRef.current;
let scrollContainer = scrollContainerCache.get( contentEl );
if ( ! scrollContainer ) {
scrollContainer = getScrollContainer( contentEl );
scrollContainerCache.set( contentEl, scrollContainer );
}
scrollContainer.scrollBy( deltaX, deltaY );
// Finds a scrollable ancestor of the event’s target. It's not cached because the
// it may not remain scrollable due to popover position changes. The cache is also
// less likely to be utilized because the target may be different every event.
const eventScrollContainer = getScrollContainer( target );
// Scrolls “through” the popover only if another contained scrollable area isn’t
// in front of it. This is to avoid scrolling both containers simultaneously.
if ( ! node.contains( eventScrollContainer ) ) {
scrollContainer.scrollBy( deltaX, deltaY );
}
}
// Tell the browser that we do not call event.preventDefault
// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners
Expand Down
Loading