diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-11-17 08:07:37 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-11-17 08:07:37 +0800 |
commit | 654c13df8aee2e43992c6629d2249d56667fec67 (patch) | |
tree | 7d9eba98917007427f1ea1906712ca726b12d8ad | |
parent | 6e2fbcdb3e17e328fc76411b352b2385838eaa3a (diff) | |
download | dexon-sol-tools-654c13df8aee2e43992c6629d2249d56667fec67.tar dexon-sol-tools-654c13df8aee2e43992c6629d2249d56667fec67.tar.gz dexon-sol-tools-654c13df8aee2e43992c6629d2249d56667fec67.tar.bz2 dexon-sol-tools-654c13df8aee2e43992c6629d2249d56667fec67.tar.lz dexon-sol-tools-654c13df8aee2e43992c6629d2249d56667fec67.tar.xz dexon-sol-tools-654c13df8aee2e43992c6629d2249d56667fec67.tar.zst dexon-sol-tools-654c13df8aee2e43992c6629d2249d56667fec67.zip |
fix: bug where we did not call onClose config
-rw-r--r-- | packages/instant/src/index.umd.ts | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/instant/src/index.umd.ts b/packages/instant/src/index.umd.ts index 9703c6fc0..518326e21 100644 --- a/packages/instant/src/index.umd.ts +++ b/packages/instant/src/index.umd.ts @@ -53,14 +53,19 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z injectedDiv.setAttribute('id', INJECTED_DIV_ID); injectedDiv.setAttribute('class', INJECTED_DIV_CLASS); appendTo.appendChild(injectedDiv); - const removeFromDom = () => appendTo.removeChild(injectedDiv); + const closeInstant = () => { + if (config.onClose) { + config.onClose(); + } + appendTo.removeChild(injectedDiv); + }; const instantOverlayProps = { ...config, // If we are using the history API, just go back to close - onClose: () => (config.shouldDisablePushToHistory ? removeFromDom() : window.history.back()), + onClose: () => (config.shouldDisablePushToHistory ? closeInstant() : window.history.back()), }; ReactDOM.render(React.createElement(ZeroExInstantOverlay, instantOverlayProps), injectedDiv); - return removeFromDom; + return closeInstant; }; if (config.shouldDisablePushToHistory) { renderInstant(); @@ -83,9 +88,6 @@ export const render = (config: ZeroExInstantConfig, selector: string = DEFAULT_Z } else { // User pressed back, so close instant. removeInstant(); - if (!_.isUndefined(config.onClose)) { - config.onClose(); - } } }; } |