Skip to content

Commit

Permalink
fix(searchbox): unmount component on dispose (#3563)
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour authored Mar 2, 2019
1 parent b0430ca commit c3f0435
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/widgets/search-box/search-box.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { render } from 'preact-compat';
import React, { render, unmountComponentAtNode } from 'preact-compat';
import cx from 'classnames';
import {
getContainerNode,
Expand Down Expand Up @@ -43,12 +43,6 @@ const renderer = ({
);
};

const disposer = containerNode => () => {
const range = document.createRange(); // IE10+
range.selectNodeContents(containerNode);
range.deleteContents();
};

/**
* @typedef {Ojbect} SearchBoxTemplates
* @property {function|string} submit Template used for displaying the submit. Can accept a function or a Hogan string.
Expand Down Expand Up @@ -177,9 +171,8 @@ You may want to migrate using \`connectSearchBox\`: ${createDocumentationLink({
showLoadingIndicator,
});

const makeWidget = connectSearchBox(
specializedRenderer,
disposer(containerNode)
const makeWidget = connectSearchBox(specializedRenderer, () =>
unmountComponentAtNode(containerNode)
);

return makeWidget({ queryHook });
Expand Down

0 comments on commit c3f0435

Please sign in to comment.