From 2883429bcc3f92c286f09e9e1346848f2d45a332 Mon Sep 17 00:00:00 2001 From: Luna McNulty Date: Mon, 9 Sep 2024 14:19:55 -0400 Subject: [PATCH] Fix notes field breaking table in classifications editor preview (#3055) --- .../src/components/taxa/Taxonomy.js | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/site/gatsby-site/src/components/taxa/Taxonomy.js b/site/gatsby-site/src/components/taxa/Taxonomy.js index d5327bf1b1..88c815dbad 100644 --- a/site/gatsby-site/src/components/taxa/Taxonomy.js +++ b/site/gatsby-site/src/components/taxa/Taxonomy.js @@ -112,28 +112,27 @@ const Taxonomy = ({ taxonomy, incidentId, reportNumber, canEdit, initialEditing ${singleColumn ? 'grid-cols-[1fr_3fr]' : 'lg:grid-cols-[repeat(4,_auto)]'} `} > - {canEdit && ( -
-
- -

{'Notes'}

-
-
- {taxonomy.notes} -
- )} - {(showAllClassifications ? taxonomy.classificationsArray : topClassifications) - .filter( - (field) => !(field.renderAs === 'description_toggle' && field.value == 'No') + {['dummy-notes'] + .concat( + (showAllClassifications + ? taxonomy.classificationsArray + : topClassifications.slice(canEdit ? 1 : 0) + ) + .filter( + (field) => !(field.renderAs === 'description_toggle' && field.value == 'No') + ) + .map((field) => { + if (field.renderAs === 'description_toggle') { + return { ...field, value: field.longDescription }; + } + + return field; + }) ) - .map((field) => { - if (field.renderAs === 'description_toggle') { - return { ...field, value: field.longDescription }; - } - - return field; - }) + .filter((field) => canEdit || field !== 'dummy-notes') .map((field, i) => { + const showNotes = field === 'dummy-notes'; + const isFirst = singleColumn ? i == 0 : i < 2; const isLast = singleColumn @@ -154,11 +153,15 @@ const Taxonomy = ({ taxonomy, incidentId, reportNumber, canEdit, initialEditing ${isLast ? 'border-b-0' : ''} `} > - -

- {field.name} {field.renderAs} -

-
+ {showNotes ? ( +

Notes

+ ) : ( + +

+ {field.name} {field.renderAs} +

+
+ )} - {field.value} + {showNotes ? taxonomy.notes : field.value} );