Skip to content

Commit f14c5fd

Browse files
author
Sasha Kondrashov
committed
portal
1 parent 9b4fda8 commit f14c5fd

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/addons/Portal/Portal.d.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,35 @@ export interface StrictPortalProps {
5050
* Called when a close event happens
5151
*
5252
* @param {SyntheticEvent} event - React's original SyntheticEvent.
53-
* @param {object} data - All props.
53+
* @param {object} props - All props.
54+
* @param {boolean} open - Whether or not the portal is displayed.
5455
*/
55-
onClose?: (event: React.MouseEvent<HTMLElement>, data: PortalProps) => void
56+
onClose?: (event: React.MouseEvent<HTMLElement>, props: PortalProps, open: boolean) => void
5657

5758
/**
5859
* Called when the portal is mounted on the DOM
5960
*
6061
* @param {null}
61-
* @param {object} data - All props.
62+
* @param {object} props - All props.
6263
*/
63-
onMount?: (nothing: null, data: PortalProps) => void
64+
onMount?: (nothing: null, props: PortalProps) => void
6465

6566
/**
6667
* Called when an open event happens
6768
*
6869
* @param {SyntheticEvent} event - React's original SyntheticEvent.
69-
* @param {object} data - All props.
70+
* @param {object} props - All props.
71+
* @param {boolean} open - Whether or not the portal is displayed.
7072
*/
71-
onOpen?: (event: React.MouseEvent<HTMLElement>, data: PortalProps) => void
73+
onOpen?: (event: React.MouseEvent<HTMLElement>, props: PortalProps, open: boolean) => void
7274

7375
/**
7476
* Called when the portal is unmounted from the DOM
7577
*
7678
* @param {null}
77-
* @param {object} data - All props.
79+
* @param {object} props - All props.
7880
*/
79-
onUnmount?: (nothing: null, data: PortalProps) => void
81+
onUnmount?: (nothing: null, props: PortalProps) => void
8082

8183
/** Controls whether or not the portal is displayed. */
8284
open?: boolean

src/addons/Portal/Portal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Portal(props) {
6161
debug('open()')
6262

6363
setOpen(true)
64-
_.invoke(props, 'onOpen', e, { ...props, open: true })
64+
_.invoke(props, 'onOpen', e, props, true)
6565
}
6666

6767
const openPortalWithTimeout = (e, delay) => {
@@ -77,7 +77,7 @@ function Portal(props) {
7777
debug('close()')
7878

7979
setOpen(false)
80-
_.invoke(props, 'onClose', e, { ...props, open: false })
80+
_.invoke(props, 'onClose', e, props, false)
8181
}
8282

8383
const closePortalWithTimeout = (e, delay) => {

test/specs/addons/Portal/Portal-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('Portal', () => {
181181

182182
wrapper.find('#trigger').simulate('click')
183183
onOpen.should.have.been.calledOnce()
184-
onOpen.should.have.been.calledWithMatch({}, { open: true })
184+
onOpen.should.have.been.calledWithMatch({}, {}, true)
185185
})
186186
})
187187

@@ -196,7 +196,7 @@ describe('Portal', () => {
196196

197197
domEvent.click(document.body)
198198
onClose.should.have.been.called()
199-
onClose.should.have.been.calledWithMatch({}, { open: false })
199+
onClose.should.have.been.calledWithMatch({}, {}, false)
200200
})
201201
})
202202

0 commit comments

Comments
 (0)