Skip to content

Commit

Permalink
chore: reset popover values when it closed
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalgrg519 committed Jan 16, 2025
1 parent 2f6de96 commit c10197c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
7 changes: 7 additions & 0 deletions ui/web-v2/src/components/FilterPopover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export const FilterPopover: FC<FilterPopoverProps> = memo(
}
};

const handlePopoverClose = () => {
setSelectedFilterType(null);
setValueOption(null);
setMultiValueOption([]);
};

useEffect(() => {
if (isFilterTypeMaintainer) {
setValueOption(null);
Expand Down Expand Up @@ -83,6 +89,7 @@ export const FilterPopover: FC<FilterPopoverProps> = memo(
leave="transition ease-in duration-150"
leaveFrom="opacity-100 translate-y-0"
leaveTo="opacity-0 translate-y-1"
afterLeave={handlePopoverClose}
>
<Popover.Panel
className={classNames(
Expand Down
28 changes: 17 additions & 11 deletions ui/web-v2/src/pages/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ export const AccountIndexPage: FC = memo(() => {
`${PAGE_PATH_ROOT}${currentEnvironment.urlCode}${PAGE_PATH_ACCOUNTS}`
);
updateAccountList(null, 1);
fetchListTags();
});
},
[dispatch]
Expand Down Expand Up @@ -433,11 +434,25 @@ export const AccountIndexPage: FC = memo(() => {
})
);
handleClose();
fetchListTags();
});
},
[dispatch, accountId, dirtyFields]
);

const fetchListTags = useCallback(() => {
dispatch(
listTags({
environmentId: currentEnvironment.id,
pageSize: 99999,
cursor: '',
orderBy: ListTagsRequest.OrderBy.DEFAULT,
orderDirection: ListTagsRequest.OrderDirection.ASC,
searchKeyword: null
})
);
}, [dispatch]);

useEffect(() => {
history.listen(() => {
// Handle browser's back button
Expand All @@ -454,17 +469,8 @@ export const AccountIndexPage: FC = memo(() => {
searchOptions,
searchOptions.page ? Number(searchOptions.page) : 1
);
dispatch(
listTags({
environmentId: currentEnvironment.id,
pageSize: 99999,
cursor: '',
orderBy: ListTagsRequest.OrderBy.DEFAULT,
orderDirection: ListTagsRequest.OrderDirection.ASC,
searchKeyword: null
})
);
}, [updateAccountList, dispatch]);
fetchListTags();
}, [updateAccountList]);

useEffect(() => {
if (isUpdate) {
Expand Down

0 comments on commit c10197c

Please sign in to comment.