diff --git a/src/components/SettingsPage/sections/Currencies.js b/src/components/SettingsPage/sections/Currencies.js index 500641db..b7e65a9b 100644 --- a/src/components/SettingsPage/sections/Currencies.js +++ b/src/components/SettingsPage/sections/Currencies.js @@ -145,5 +145,4 @@ class TabCurrencies extends PureComponent { } } -// $FlowFixMe not sure what's wrong export default connect(mapStateToProps)(TabCurrencies) diff --git a/src/components/base/GrowScroll/index.js b/src/components/base/GrowScroll/index.js index 7c651c1b..a4d154f1 100644 --- a/src/components/base/GrowScroll/index.js +++ b/src/components/base/GrowScroll/index.js @@ -5,7 +5,6 @@ import React, { PureComponent } from 'react' import Scrollbar from 'react-smooth-scrollbar' import SmoothScrollbar, { ScrollbarPlugin } from 'smooth-scrollbar' -import noop from 'lodash/noop' import Box from 'components/base/Box' @@ -13,42 +12,55 @@ type Props = { children: any, full: boolean, maxHeight?: number, - onUpdate: Function, - onScroll: Function, + onUpdate?: (*) => void, + onScroll?: () => void, } +// TODO this component is the source of junky scroll experience. need better solution ASAP class GrowScroll extends PureComponent { static defaultProps = { full: false, - onUpdate: noop, - onScroll: noop, } componentDidMount() { - this.handleUpdate(this.props) - - if (this._scrollbar) { - this._scrollbar.addListener(this.props.onScroll) + const { onUpdate, onScroll } = this.props + const { _scrollbar } = this + if (_scrollbar) { + if (onUpdate) { + onUpdate(_scrollbar) + } + if (onScroll) { + _scrollbar.addListener(this.onScroll) + } } } componentWillUnmount() { - if (this._scrollbar) { - this._scrollbar.removeListener(this.props.onScroll) + const { onScroll } = this.props + const { _scrollbar } = this + if (_scrollbar && onScroll) { + _scrollbar.removeListener(this.onScroll) } } componenDidUpdate() { - this.handleUpdate(this.props) + const { onUpdate } = this.props + const { _scrollbar } = this + if (_scrollbar && onUpdate) { + onUpdate(_scrollbar) + } } - handleUpdate = (props: Props) => { - if (this._scrollbar) { - props.onUpdate(this._scrollbar) - } + onScroll = () => { + const { onScroll } = this.props + if (onScroll) onScroll() + } + + onRef = (ref: ?Scrollbar) => { + this._scrollbar = ref && ref.scrollbar } - _scrollbar = undefined + _scrollbar: * render() { const { onUpdate, children, maxHeight, full, ...props } = this.props @@ -79,7 +91,7 @@ class GrowScroll extends PureComponent { top: 0, }), }} - ref={r => r && (this._scrollbar = r.scrollbar)} + ref={this.onRef} > {children} diff --git a/src/components/layout/Default.js b/src/components/layout/Default.js index aac00084..8c9d7127 100644 --- a/src/components/layout/Default.js +++ b/src/components/layout/Default.js @@ -50,17 +50,6 @@ class Default extends Component { clearTimeout(this._timeout) } - handleScroll = () => { - document.querySelectorAll('.tippy-popper').forEach((p: any) => { - const instance = p._tippy - - if (instance.state.visible) { - instance.popperInstance.disableEventListeners() - instance.hide(0) - } - }) - } - _timeout = undefined _scrollContainer = null @@ -79,7 +68,7 @@ class Default extends Component { - (this._scrollContainer = n)} onScroll={this.handleScroll}> + (this._scrollContainer = n)}>