diff --git a/front/src/applications/stdcm/components/StdcmForm/StdcmOperationalPoint.tsx b/front/src/applications/stdcm/components/StdcmForm/StdcmOperationalPoint.tsx
index 723f2a46472..c1ac54016db 100644
--- a/front/src/applications/stdcm/components/StdcmForm/StdcmOperationalPoint.tsx
+++ b/front/src/applications/stdcm/components/StdcmForm/StdcmOperationalPoint.tsx
@@ -44,8 +44,9 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
const {
searchTerm,
setSearchTerm,
- sortedSearchResults: searchResults,
+ searchResults,
setSearchResults,
+ searchOperationalPointsByTrigram,
} = useSearchOperationalPoint({
initialSearchTerm: location?.name,
initialChCodeFilter: location?.secondary_code,
@@ -103,14 +104,17 @@ const StdcmOperationalPoint = ({ location, pathStepId, disabled }: StdcmOperatio
[searchResults]
);
- const handleCiSelect = (selectedSuggestion?: CIOption) => {
+ const handleCiSelect = async (selectedSuggestion?: CIOption) => {
+ dispatch(updateStdcmPathStep({ id: pathStepId, updates: { location: selectedSuggestion } }));
if (selectedSuggestion) {
- const newChSuggestions = extractChCodes(searchResults, selectedSuggestion);
+ const operationalPointParts = await searchOperationalPointsByTrigram(
+ selectedSuggestion.trigram
+ );
+ const newChSuggestions = extractChCodes(operationalPointParts, selectedSuggestion);
setChSuggestions(newChSuggestions);
} else {
setChSuggestions([]);
}
- dispatch(updateStdcmPathStep({ id: pathStepId, updates: { location: selectedSuggestion } }));
};
const handleChSelect = (selectedChCode?: CHOption) => {
diff --git a/front/src/common/Map/Search/MapSearchOperationalPoint.tsx b/front/src/common/Map/Search/MapSearchOperationalPoint.tsx
index 7151b21a3cb..1635700a5f8 100644
--- a/front/src/common/Map/Search/MapSearchOperationalPoint.tsx
+++ b/front/src/common/Map/Search/MapSearchOperationalPoint.tsx
@@ -28,8 +28,8 @@ const MapSearchOperationalPoint = ({
const {
searchTerm,
chCodeFilter,
- sortedSearchResults,
- filteredAndSortedSearchResults,
+ searchResults,
+ searchResultsFilteredByCh,
mainOperationalPointsOnly,
setSearchTerm,
setChCodeFilter,
@@ -57,7 +57,7 @@ const MapSearchOperationalPoint = ({
switch (event.key) {
case 'ArrowUp':
setSelectedResultIndex((prevIndex) => {
- const newIndex = prevIndex > 0 ? prevIndex - 1 : sortedSearchResults.length - 1;
+ const newIndex = prevIndex > 0 ? prevIndex - 1 : searchResults.length - 1;
const element = document.getElementById(`result-${newIndex}`);
if (element) {
element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
@@ -67,7 +67,7 @@ const MapSearchOperationalPoint = ({
break;
case 'ArrowDown':
setSelectedResultIndex((prevIndex) => {
- const newIndex = prevIndex < sortedSearchResults.length - 1 ? prevIndex + 1 : 0;
+ const newIndex = prevIndex < searchResults.length - 1 ? prevIndex + 1 : 0;
const element = document.getElementById(`result-${newIndex}`);
if (element) {
element.scrollIntoView({ block: 'nearest', inline: 'nearest' });
@@ -133,16 +133,16 @@ const MapSearchOperationalPoint = ({
- {sortedSearchResults.length > 100
+ {searchResults.length > 100
? t('resultsCountTooMuch')
: t('resultsCount', {
- count: filteredAndSortedSearchResults.length,
+ count: searchResultsFilteredByCh.length,
})}
- {sortedSearchResults.length > 0 &&
- sortedSearchResults.length <= 100 &&
- filteredAndSortedSearchResults.map((searchResult, index) => (
+ {searchResults.length > 0 &&
+ searchResults.length <= 100 &&
+ searchResultsFilteredByCh.map((searchResult, index) => (