Skip to content

Commit

Permalink
IBX-7677: Remove markedLocationId reset to null from useSearchByQuery…
Browse files Browse the repository at this point in the history
…Fetch (#1172)
  • Loading branch information
tischsoic authored Feb 15, 2024
1 parent e88c235 commit b4b49bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import ContentTable from '../content-table/content.table';
import Filters from '../filters/filters';
import SearchTags from './search.tags';
import { useSearchByQueryFetch } from '../../hooks/useSearchByQueryFetch';
import { AllowedContentTypesContext, SearchTextContext } from '../../universal.discovery.module';
import { AllowedContentTypesContext, MarkedLocationIdContext, SearchTextContext } from '../../universal.discovery.module';
import { createCssClassNames } from '../../../common/helpers/css.class.names';
import { getAdminUiConfig, getTranslator } from '@ibexa-admin-ui/src/bundle/Resources/public/js/scripts/helpers/context.helper';

Expand All @@ -33,6 +33,7 @@ const Search = ({ itemsPerPage }) => {
const Translator = getTranslator();
const adminUiConfig = getAdminUiConfig();
const allowedContentTypes = useContext(AllowedContentTypesContext);
const [, setMarkedLocationId] = useContext(MarkedLocationIdContext);
const [searchText] = useContext(SearchTextContext);
const [offset, setOffset] = useState(0);
const [selectedContentTypes, dispatchSelectedContentTypesAction] = useReducer(selectedContentTypesReducer, []);
Expand Down Expand Up @@ -61,6 +62,7 @@ const Search = ({ itemsPerPage }) => {

const contentTypes = !!selectedContentTypes.length ? [...selectedContentTypes] : allowedContentTypes;

setMarkedLocationId(null);
searchByQuery(searchText, contentTypes, selectedSection, selectedSubtree, itemsPerPage, offset, selectedLanguage);
};
const changePage = (pageIndex) => setOffset(pageIndex * itemsPerPage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useCallback, useReducer } from 'react';

import { findLocationsBySearchQuery } from '../services/universal.discovery.service';
import { RestInfoContext, LoadedLocationsMapContext, MarkedLocationIdContext } from '../universal.discovery.module';
import { RestInfoContext, LoadedLocationsMapContext } from '../universal.discovery.module';

const SEARCH_START = 'SEARCH_START';
const SEARCH_END = 'SEARCH_END';
Expand All @@ -22,7 +22,6 @@ const searchByQueryReducer = (state, action) => {

export const useSearchByQueryFetch = () => {
const restInfo = useContext(RestInfoContext);
const [, setMarkedLocationId] = useContext(MarkedLocationIdContext);
const [, dispatchLoadedLocationsAction] = useContext(LoadedLocationsMapContext);
const [{ isLoading, data }, dispatch] = useReducer(searchByQueryReducer, { isLoading: false, data: {} });
const searchByQuery = useCallback(
Expand All @@ -41,7 +40,6 @@ export const useSearchByQueryFetch = () => {
contentNameCriterion = null,
) => {
const handleFetch = (response) => {
setMarkedLocationId(null);
dispatchLoadedLocationsAction({ type: 'CLEAR_LOCATIONS' });
dispatch({ type: SEARCH_END, response });
};
Expand Down

0 comments on commit b4b49bd

Please sign in to comment.