Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Page.Action: Add guard for IntersectionObserver (#628)
Browse files Browse the repository at this point in the history
This update adds a guard for `IntersectionObserver`, which is used for the
sticky feature in `Page.Action`.

The issue would only occur JSDOM. Target browsers (Edge+) supports this
feature
  • Loading branch information
Jon Quach committed May 16, 2019
1 parent dbade79 commit f62f9bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/components/Page/Page.Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class Actions extends React.PureComponent<
zIndex,
...rest
} = this.props
const { isStickyActive } = this.state

const content = (
<ActionsUI
Expand Down
6 changes: 6 additions & 0 deletions src/components/Page/Page.StickyActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class StickyActions extends React.PureComponent<
}

observerStart() {
/* istanbul ignore next */
if (!IntersectionObserver) return

const { offset } = this.props
const observerOptions = {
root: null,
Expand All @@ -46,6 +49,9 @@ class StickyActions extends React.PureComponent<
}

observerStop() {
/* istanbul ignore next */
if (!IntersectionObserver) return

this.observer.unobserve(this.node)
this.observer.disconnect()
}
Expand Down

0 comments on commit f62f9bc

Please sign in to comment.