Skip to content

Commit

Permalink
fix: mark section filters correctly when navigating to search page fr…
Browse files Browse the repository at this point in the history
…om page header (#401)

* fix: added customPath to SearchSectionForm doSearch function to set query.path

* chore: updated RELEASE.md

* chore: removed console.log

* chore: removed conflicts in RELEASE.md

* fix: removed dispatch, left old implementation together with new ones for custom paths

---------

Co-authored-by: Piero Nicolli <[email protected]>
  • Loading branch information
sabrina-bongiovanni and pnicolli authored Nov 14, 2023
1 parent 0df93a5 commit fdc6207
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

### Fix

- Quando viene effettuata una ricerca dalla barra di ricerca nelle sezioni Amministrazione, Servizi, Novità, o Documenti e Dati, viene automaticamente impostato il filtro sulla sezione stessa così da mostrare solo i contenuti corrispondenti.
- Le icone del Blocco Numeri, del Blocco Icone e della Sidebar si aggiornano istantaneamente quando vengono cambiate
- Sistemato un bug nell'header dei sottositi che mostrava le voci del menu del sito padre anche se queste erano indicate come non visibili nella configurazione del menu.

Expand Down
27 changes: 24 additions & 3 deletions src/components/ItaliaTheme/View/Commons/SearchSectionForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ const messages = defineMessages({

const SearchSectionForm = ({ content }) => {
const intl = useIntl();
const path = content['@id'];
const searchFilters = useSelector(
(state) => state?.searchFilters?.result?.sections,
);

const customPath = [];

const sections = searchFilters?.[0]?.items ?? [];

sections.forEach((section) => {
if (!section.items) {
return;
} else {
if (path === section['@id']) {
customPath.push(
section.items.map((item) => flattenToAppURL(item['@id'])),
);
}
}
});

const subsite = useSelector((state) => state.subsite?.data);
const [searchableText, setSearchableText] = useState('');
Expand All @@ -44,13 +64,14 @@ const SearchSectionForm = ({ content }) => {
{},
null,
null,
null,
customPath.length > 0 ? customPath : null,
subsite,
intl.locale,
false,
) +
'&custom_path=' +
flattenToAppURL(content['@id']);
(customPath.length === 0
? `&custom_path=${flattenToAppURL(path)}`
: '');
}
};
return (
Expand Down

0 comments on commit fdc6207

Please sign in to comment.