0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-01 02:41: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 GitHub
parent 265a8dd16f
commit 7f3731e9d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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;
};