From daf7814d0ce7b9c1312498e598918e2ef0e7dc24 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 12 Jul 2021 10:00:35 +0200 Subject: [PATCH] Update getTermsInfo() to workaround parsing issue for translatable strings (#33341) --- packages/block-library/src/query/utils.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/query/utils.js b/packages/block-library/src/query/utils.js index d8edac0adb145..6ff6e026e08b3 100644 --- a/packages/block-library/src/query/utils.js +++ b/packages/block-library/src/query/utils.js @@ -39,9 +39,8 @@ import { store as coreStore } from '@wordpress/core-data'; * @param {WPTerm[]} terms The terms to extract of helper object. * @return {QueryTermsInfo} The object with the terms information. */ -export const getTermsInfo = ( terms ) => ( { - terms, - ...terms?.reduce( +export const getTermsInfo = ( terms ) => { + const mapping = terms?.reduce( ( accumulator, term ) => { const { mapById, mapByName, names } = accumulator; mapById[ term.id ] = term; @@ -50,8 +49,13 @@ export const getTermsInfo = ( terms ) => ( { return accumulator; }, { mapById: {}, mapByName: {}, names: [] } - ), -} ); + ); + + return { + terms, + ...mapping, + }; +}; /** * Returns a helper object that contains: