Explore tree reset (#17653)

* reset tree state when quick filter is empty

* cleanup

(cherry picked from commit 55cbda4ea568dba1e54f1ea4671026ecdf6a3121)
This commit is contained in:
Karan Hotchandani 2024-08-30 21:37:08 +05:30 committed by karanh37
parent 34f94b8ed2
commit e5e39f75f3
2 changed files with 12 additions and 3 deletions

View File

@ -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);

View File

@ -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';
@ -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)
@ -89,7 +89,7 @@ const ExploreTree = ({ onFieldValueSelect }: ExploreTreeProps) => {
? parsedSearch.search
: '';
return [searchQueryParam, defaultServiceType];
return [parsedSearch, searchQueryParam, defaultServiceType];
}, [location.search]);
const handleChangeSearchIndex = (
@ -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