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:
parent
265a8dd16f
commit
7f3731e9d1
1 changed files with 9 additions and 3 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue