From 53eb88d9a9084a445cc5700bd5231578c7e96756 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 19 Jul 2023 17:52:19 -0700 Subject: [PATCH] Fixed: Translations for columns (cherry picked from commit 6d53d2a153a98070c42d0619c15902b6bd5dfab4) --- frontend/src/Components/Icon.js | 4 ++-- .../src/Store/Middleware/createPersistState.js | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/Components/Icon.js b/frontend/src/Components/Icon.js index e8c7c5178..d200b8c08 100644 --- a/frontend/src/Components/Icon.js +++ b/frontend/src/Components/Icon.js @@ -41,7 +41,7 @@ class Icon extends PureComponent { return ( {icon} @@ -58,7 +58,7 @@ Icon.propTypes = { name: PropTypes.object.isRequired, kind: PropTypes.string.isRequired, size: PropTypes.number.isRequired, - title: PropTypes.string, + title: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), isSpinning: PropTypes.bool.isRequired, fixedWidth: PropTypes.bool.isRequired }; diff --git a/frontend/src/Store/Middleware/createPersistState.js b/frontend/src/Store/Middleware/createPersistState.js index 6e94c84e5..6950c49d4 100644 --- a/frontend/src/Store/Middleware/createPersistState.js +++ b/frontend/src/Store/Middleware/createPersistState.js @@ -36,10 +36,17 @@ function mergeColumns(path, initialState, persistedState, computedState) { const column = initialColumns.find((i) => i.name === persistedColumn.name); if (column) { - columns.push({ - ...column, - isVisible: persistedColumn.isVisible - }); + const newColumn = {}; + + // We can't use a spread operator or Object.assign to clone the column + // or any accessors are lost and can break translations. + for (const prop of Object.keys(column)) { + Object.defineProperty(newColumn, prop, Object.getOwnPropertyDescriptor(column, prop)); + } + + newColumn.isVisible = persistedColumn.isVisible; + + columns.push(newColumn); } });