Skip to content

Commit

Permalink
WIP unique eventStack
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc Merceron committed Jul 27, 2018
1 parent 085439c commit 1ae4cae
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/addons/Portal/Portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ import _ from 'lodash'
import PropTypes from 'prop-types'
import React, { cloneElement } from 'react'

import {
AutoControlledComponent as Component,
doesNodeContainClick,
eventStack,
makeDebugger,
} from '../../lib'
import { AutoControlledComponent as Component, doesNodeContainClick, makeDebugger } from '../../lib'

import EventStack from '../../lib/eventStack/EventStack'
import Ref from '../Ref'
import PortalInner from './PortalInner'

Expand Down Expand Up @@ -129,6 +126,8 @@ class Portal extends Component {

static Inner = PortalInner

eventStack = new EventStack()

componentWillUnmount() {
// Clean up timers
clearTimeout(this.mouseEnterTimer)
Expand Down Expand Up @@ -307,10 +306,10 @@ class Portal extends Component {

this.portalNode = target

eventStack.sub('mouseleave', this.handlePortalMouseLeave, { pool: eventPool, target })
eventStack.sub('mouseenter', this.handlePortalMouseEnter, { pool: eventPool, target })
eventStack.sub('click', this.handleDocumentClick, { pool: eventPool })
eventStack.sub('keydown', this.handleEscape, { pool: eventPool })
this.eventStack.sub('mouseleave', this.handlePortalMouseLeave, { pool: eventPool, target })
this.eventStack.sub('mouseenter', this.handlePortalMouseEnter, { pool: eventPool, target })
this.eventStack.sub('click', this.handleDocumentClick, { pool: eventPool })
this.eventStack.sub('keydown', this.handleEscape, { pool: eventPool })

_.invoke(this.props, 'onMount', null, this.props)
}
Expand All @@ -321,10 +320,10 @@ class Portal extends Component {

this.portalNode = null

eventStack.unsub('mouseleave', this.handlePortalMouseLeave, { pool: eventPool, target })
eventStack.unsub('mouseenter', this.handlePortalMouseEnter, { pool: eventPool, target })
eventStack.unsub('click', this.handleDocumentClick, { pool: eventPool })
eventStack.unsub('keydown', this.handleEscape, { pool: eventPool })
this.eventStack.unsub('mouseleave', this.handlePortalMouseLeave, { pool: eventPool, target })
this.eventStack.unsub('mouseenter', this.handlePortalMouseEnter, { pool: eventPool, target })
this.eventStack.unsub('click', this.handleDocumentClick, { pool: eventPool })
this.eventStack.unsub('keydown', this.handleEscape, { pool: eventPool })

_.invoke(this.props, 'onUnmount', null, this.props)
}
Expand Down

0 comments on commit 1ae4cae

Please sign in to comment.