Skip to content

Commit

Permalink
Taxonomies: Retain flat term order
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham committed Aug 13, 2024
1 parent c73aa36 commit 958c94f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
per_page: -1,
};

const _terms = _termIds?.length
? getEntityRecords( 'taxonomy', slug, query )
: EMPTY_ARRAY;

return {
hasCreateAction: _taxonomy
? post._links?.[
Expand All @@ -116,8 +120,10 @@ export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
: false,
taxonomy: _taxonomy,
termIds: _termIds,
terms: _termIds?.length
? getEntityRecords( 'taxonomy', slug, query )
terms: _terms
? _termIds.map( ( termId ) =>
_terms.find( ( term ) => term.id === termId )
)
: EMPTY_ARRAY,
hasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [
'taxonomy',
Expand Down

0 comments on commit 958c94f

Please sign in to comment.