Skip to content

Commit

Permalink
fix(@react-aria/overlays): prevent exception on Cypress
Browse files Browse the repository at this point in the history
Cypress screenshot command triggers a scroll event where the event target is window, not a DOM element.

closes #2340
  • Loading branch information
alirezamirian committed Sep 16, 2021
1 parent e0d42c4 commit dafc3ce
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/@react-aria/overlays/src/useCloseOnScroll.ts
Expand Up @@ -36,8 +36,8 @@ export function useCloseOnScroll(opts: CloseOnScrollOptions) {

let onScroll = (e: MouseEvent) => {
// Ignore if scrolling an scrollable region outside the trigger's tree.
let target = e.target as HTMLElement;
if (!triggerRef.current || !target.contains(triggerRef.current)) {
let target = e.target;
if (!triggerRef.current || !(target instanceof HTMLElement) || !target.contains(triggerRef.current)) {
return;
}

Expand Down

0 comments on commit dafc3ce

Please sign in to comment.