From 0e77e64da118b584b5e1c6f94452b710dcd53991 Mon Sep 17 00:00:00 2001 From: Mateusz Borowczyk Date: Tue, 30 Apr 2024 09:53:08 +0200 Subject: [PATCH] Fix issue with integers passed through expert mode as a string (Issue #5718, PR #5722) # Description * Short description here * closes #5718 # Self Check: Strike through any lines that are not applicable (`~~line~~`) then check the box - [x] Attached issue to pull request - [x] Changelog entry - [x] Code is clear and sufficiently documented - [x] Sufficient test cases (reproduces the bug/tests the requested feature) - [x] Correct, in line with design - [ ] End user documentation is included or an issue is created for end-user documentation (add ref to issue here: ) --- changelogs/unreleased/5718-expert-mode-fix.yml.yml | 6 ++++++ .../TreeTable/TreeRow/CellWithCopyExpert.test.tsx | 2 +- src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.tsx | 7 +++++-- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/5718-expert-mode-fix.yml.yml diff --git a/changelogs/unreleased/5718-expert-mode-fix.yml.yml b/changelogs/unreleased/5718-expert-mode-fix.yml.yml new file mode 100644 index 000000000..0f26c4c5a --- /dev/null +++ b/changelogs/unreleased/5718-expert-mode-fix.yml.yml @@ -0,0 +1,6 @@ +description: "Fix issue with integers passed through expert mode as a string" +issue-nr: 5718 +change-type: patch +destination-branches: [master, iso7] +sections: + bugfix: "{{description}}" diff --git a/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.test.tsx b/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.test.tsx index 0e5eb6777..834f4c93e 100644 --- a/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.test.tsx +++ b/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.test.tsx @@ -543,7 +543,7 @@ test.each` target: "parent", value: { id: "09042sev-1235-f234-ktgd-cc45615ba782", - editedValue: newValue, + editedValue: expectedValue, unedited: "value", }, }, diff --git a/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.tsx b/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.tsx index 6dcd3d90b..a3ea92766 100644 --- a/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.tsx +++ b/src/UI/Components/TreeTable/TreeRow/CellWithCopyExpert.tsx @@ -99,11 +99,12 @@ export const CellWithCopyExpert: React.FC = ({ if (attributeType.includes("int")) { const tempFormat = parseInt(newAttribute as unknown as string); - formattedAttr = isNaN(tempFormat) ? tempFormat : newAttribute; + formattedAttr = isNaN(tempFormat) ? newAttribute : tempFormat; } else if (attributeType.includes("float")) { const tempFormat = parseFloat(newAttribute as unknown as string); - formattedAttr = isNaN(tempFormat) ? tempFormat : newAttribute; + formattedAttr = isNaN(tempFormat) ? newAttribute : tempFormat; } + if (parentObject) { newValue = parentObject[path.split("$")[0]]; set( @@ -111,6 +112,8 @@ export const CellWithCopyExpert: React.FC = ({ path.split("$").slice(1).join("."), formattedAttr, ); + } else { + newValue = formattedAttr; } const result = await trigger(