Skip to content

Commit c3f0435

Browse files
fix(searchbox): unmount component on dispose (#3563)
1 parent b0430ca commit c3f0435

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/widgets/search-box/search-box.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { render } from 'preact-compat';
1+
import React, { render, unmountComponentAtNode } from 'preact-compat';
22
import cx from 'classnames';
33
import {
44
getContainerNode,
@@ -43,12 +43,6 @@ const renderer = ({
4343
);
4444
};
4545

46-
const disposer = containerNode => () => {
47-
const range = document.createRange(); // IE10+
48-
range.selectNodeContents(containerNode);
49-
range.deleteContents();
50-
};
51-
5246
/**
5347
* @typedef {Ojbect} SearchBoxTemplates
5448
* @property {function|string} submit Template used for displaying the submit. Can accept a function or a Hogan string.
@@ -177,9 +171,8 @@ You may want to migrate using \`connectSearchBox\`: ${createDocumentationLink({
177171
showLoadingIndicator,
178172
});
179173

180-
const makeWidget = connectSearchBox(
181-
specializedRenderer,
182-
disposer(containerNode)
174+
const makeWidget = connectSearchBox(specializedRenderer, () =>
175+
unmountComponentAtNode(containerNode)
183176
);
184177

185178
return makeWidget({ queryHook });

0 commit comments

Comments
 (0)