Skip to content

Commit

Permalink
fix(Portal): hover behavior fixed in Portal's event handlers (#3257)
Browse files Browse the repository at this point in the history
* fix(Portal): Ignore mouseleave on children (#3239).

* fix(Portal): Add test to ignore mouseleave on Portal children (#3239).

* add line

* remove line
  • Loading branch information
Fabianopb authored and layershifter committed Nov 7, 2018
1 parent dfcbdd5 commit c26ea6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/addons/Portal/Portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class Portal extends Component {

if (!closeOnPortalMouseLeave) return

// Do not close the portal when 'mouseleave' is triggered by children
if (e.target !== this.portalNode) return

debug('handlePortalMouseLeave()')
this.mouseLeaveTimer = this.closeWithTimeout(e, mouseLeaveDelay)
}
Expand Down
19 changes: 19 additions & 0 deletions test/specs/addons/Portal/Portal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,25 @@ describe('Portal', () => {
done()
}, 1)
})

it("does not close the portal on mouseleave triggered by the portal's children", (done) => {
wrapperMount(
<Portal closeOnPortalMouseLeave defaultOpen mouseLeaveDelay={0} trigger={<button />}>
<div>
<p id='child' />
</div>
</Portal>,
)
wrapper.should.have.descendants(PortalInner)

domEvent.mouseLeave('#child')
setTimeout(() => {
wrapper.update()
wrapper.should.have.descendants(PortalInner)

done()
}, 1)
})
})

describe('closeOnTriggerMouseLeave + closeOnPortalMouseLeave', () => {
Expand Down

0 comments on commit c26ea6d

Please sign in to comment.