0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Fixed empty groups in internal link searches (#20142)

closes https://linear.app/tryghost/issue/MOM-101

- we were mapping over the grouped search results which meant we still got a group even if it's options/items list was empty after filtering for published
This commit is contained in:
Kevin Ansfield 2024-05-06 16:55:16 +01:00 committed by Sag
parent 0f482907e1
commit b24f976b34

View file

@ -326,14 +326,20 @@ export default class KoenigLexicalEditor extends Component {
}
// only published posts/pages have URLs
const filteredResults = results.map((group) => {
const filteredResults = [];
results.forEach((group) => {
const items = (group.groupName === 'Posts' || group.groupName === 'Pages') ? group.options.filter(i => i.status === 'published') : group.options;
return {
if (items.length === 0) {
return;
}
filteredResults.push({
label: group.groupName,
items
};
});
});
return filteredResults;
};