Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-7677: Remove markedLocationId reset to null from useSearchByQueryFetch #1172

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

@tischsoic tischsoic Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: we do not want to reset the marked location id with every search, so I moved it to a more specific place. (changes are related to changes from: #420)

dispatchLoadedLocationsAction({ type: 'CLEAR_LOCATIONS' });
dispatch({ type: SEARCH_END, response });
};
Expand Down
Loading