Skip to content

Commit

Permalink
Explore tree reset (#17653)
Browse files Browse the repository at this point in the history
* reset tree state when quick filter is empty

* cleanup

(cherry picked from commit 55cbda4)
  • Loading branch information
karanh37 committed Aug 30, 2024
1 parent 34f94b8 commit e5e39f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,8 @@ test.describe('Glossary tests', () => {
});

test('Request tags for Glossary', async ({ browser }) => {
test.slow(true);

const { page, afterAction, apiContext } = await performAdminLogin(browser);
const { page: page1, afterAction: afterActionUser1 } =
await performUserLogin(browser, user2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import { Tree, Typography } from 'antd';
import { AxiosError } from 'axios';
import classNames from 'classnames';
import { isString, isUndefined } from 'lodash';
import { isEmpty, isString, isUndefined } from 'lodash';
import Qs from 'qs';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useParams } from 'react-router-dom';
Expand Down Expand Up @@ -76,7 +76,7 @@ const ExploreTree = ({ onFieldValueSelect }: ExploreTreeProps) => {
return searchClassBase.getExploreTreeKey(tab as ExplorePageTabs);
}, [tab]);

const [searchQueryParam, defaultServiceType] = useMemo(() => {
const [parsedSearch, searchQueryParam, defaultServiceType] = useMemo(() => {
const parsedSearch = Qs.parse(
location.search.startsWith('?')
? location.search.substring(1)
Expand All @@ -89,7 +89,7 @@ const ExploreTree = ({ onFieldValueSelect }: ExploreTreeProps) => {
? parsedSearch.search
: '';

return [searchQueryParam, defaultServiceType];
return [parsedSearch, searchQueryParam, defaultServiceType];
}, [location.search]);

const handleChangeSearchIndex = (
Expand Down Expand Up @@ -299,6 +299,13 @@ const ExploreTree = ({ onFieldValueSelect }: ExploreTreeProps) => {
fetchEntityCounts();
}, []);

useEffect(() => {
// Tree works on the quickFilter, so we need to reset the selectedKeys when the quickFilter is empty
if (isEmpty(parsedSearch.quickFilter)) {
setSelectedKeys([]);
}
}, [parsedSearch]);

return (
<Tree
blockNode
Expand Down

0 comments on commit e5e39f7

Please sign in to comment.