Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix clear search do not reset page

sytolkbfeb96cda018
diff --git a/src/renderer/components/SearchAutocomplete.tsx b/src/renderer/components/SearchAutocomplete.tsx
index 9690ca2af..5e518c217 100644
--- a/src/renderer/components/SearchAutocomplete.tsx
+++ b/src/renderer/components/SearchAutocomplete.tsx
@@ -35,7 +35,6 @@ import {
import { FileTypeGroups, haveSearchFilters } from '-/services/search';
import { TS } from '-/tagspaces.namespace';
import { Pro } from '-/pro';
-import useFirstRender from '-/utils/useFirstRender';
import SavedSearchesMenu from '-/components/menus/SavedSearchesMenu';
import AppConfig from '-/AppConfig';
import { Autocomplete, Box, TextField } from '@mui/material';
diff --git a/src/renderer/containers/MainPage.tsx b/src/renderer/containers/MainPage.tsx
index 7fa1e4f9d..cf8484774 100644
--- a/src/renderer/containers/MainPage.tsx
+++ b/src/renderer/containers/MainPage.tsx
@@ -332,12 +332,16 @@ function MainPage(props: Props) {
setEntryInFullWidth,
} = useOpenedEntryContext();
- const { loadParentDirectoryContent, enterSearchMode, exitSearchMode } =
- useDirectoryContentContext();
+ const {
+ loadParentDirectoryContent,
+ enterSearchMode,
+ exitSearchMode,
+ openCurrentDirectory,
+ } = useDirectoryContentContext();
const { showNotification } = useNotificationContext();
const theme = useTheme();
const percent = useRef<number | undefined>(undefined);
- const [ignored, forceUpdate] = useReducer((x) => x + 1, 0);
+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
const width =
window.innerWidth ||
@@ -442,7 +446,10 @@ function MainPage(props: Props) {
setDrawerOpened(true);
},
openSearch: () => enterSearchMode(),
- closeSearch: () => exitSearchMode(),
+ closeSearch: () => {
+ exitSearchMode();
+ openCurrentDirectory();
+ },
showHelp: () => {
props.openHelpFeedbackPanel();
setDrawerOpened(true);
diff --git a/src/renderer/hooks/PaginationContextProvider.tsx b/src/renderer/hooks/PaginationContextProvider.tsx
index 1f93f27b9..ef1d692c8 100644
--- a/src/renderer/hooks/PaginationContextProvider.tsx
+++ b/src/renderer/hooks/PaginationContextProvider.tsx
@@ -42,7 +42,7 @@ export const PaginationContextProvider = ({
children,
}: PaginationContextProviderProps) => {
const initPage = 1;
- const { currentDirectoryPath } = useDirectoryContentContext();
+ const { currentDirectoryPath, isSearchMode } = useDirectoryContentContext();
const { settings, sortedDirContent } = useSortedDirContext();
const [page, setPage] = useState<number>(initPage);
@@ -59,7 +59,7 @@ export const PaginationContextProvider = ({
console.debug('meta loaded')
);
}*/
- }, [currentDirectoryPath]); //, isMetaFolderExist]);
+ }, [currentDirectoryPath, isSearchMode]); //, isMetaFolderExist]);
const pageFiles: TS.FileSystemEntry[] = useMemo(() => {
return getPageFiles(page, sortedDirContent);