diff --git a/awx/ui_next/src/components/Lookup/Lookup.jsx b/awx/ui_next/src/components/Lookup/Lookup.jsx index a90ff851ae..f168953bb5 100644 --- a/awx/ui_next/src/components/Lookup/Lookup.jsx +++ b/awx/ui_next/src/components/Lookup/Lookup.jsx @@ -186,7 +186,7 @@ class Lookup extends React.Component { const { history } = this.props; const parts = history.location.search.replace(/^\?/, '').split('&'); const ns = this.qsConfig.namespace; - const otherParts = parts.filter(param => !param.startsWith(`${ns}.`)) + const otherParts = parts.filter(param => !param.startsWith(`${ns}.`)); history.push(`${history.location.pathname}?${otherParts.join('&')}`); } diff --git a/awx/ui_next/src/components/Lookup/Lookup.test.jsx b/awx/ui_next/src/components/Lookup/Lookup.test.jsx index 186f231f11..09a44a77b8 100644 --- a/awx/ui_next/src/components/Lookup/Lookup.test.jsx +++ b/awx/ui_next/src/components/Lookup/Lookup.test.jsx @@ -359,4 +359,33 @@ describe('', () => { expect(getItems).toHaveBeenCalledTimes(2); done(); }); + + test('should clear its query params when closed', async () => { + mockData = [{ name: 'foo', id: 1, isChecked: false }]; + const history = createMemoryHistory({ + initialEntries: ['/organizations/add?inventory.name=foo&bar=baz'], + }); + wrapper = mountWithContexts( + <_Lookup + multiple + name="foo" + lookupHeader="Foo Bar" + onLookupSave={() => {}} + value={mockData} + columns={mockColumns} + sortedColumnKey="name" + getItems={() => {}} + location={{ history }} + history={history} + qsNamespace="inventory" + i18n={{ _: val => val.toString() }} + /> + ); + wrapper + .find('InputGroup Button') + .at(0) + .invoke('onClick')(); + wrapper.find('Modal').invoke('onClose')(); + expect(history.location.search).toEqual('?bar=baz'); + }); });