Skip to content

Commit 8f49c1e

Browse files
authored
Attempted fix for #74 - rendering non scalar values (#75)
* Attempted fix for #74 - rendering non scalar values If we have set value as html i.e. wrapped in the pre tag do not put it inside a `p` they are not allowed block level elements. Instead wrap in a `div` and do not render html into `title` attribute. * Lint fixes
1 parent ae15b33 commit 8f49c1e

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

src/panelTable.tsx

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const PanelTable = ({
4040
}, [collapseAll]);
4141

4242
let value = fieldsValues ? get(fieldsValues, name) : '';
43+
let isValueWrappedInPre = false;
4344

4445
if (!isUndefined(value)) {
4546
if (isObject(value)) {
@@ -51,6 +52,7 @@ const PanelTable = ({
5152
</code>
5253
</pre>
5354
);
55+
isValueWrappedInPre = true;
5456
} catch {
5557
value = <span>[Nested Object]</span>;
5658
}
@@ -235,16 +237,29 @@ const PanelTable = ({
235237
...paraGraphDefaultStyle,
236238
}}
237239
>
238-
<p
239-
title={value}
240-
style={{
241-
...paraGraphDefaultStyle,
242-
margin: 0,
243-
padding: 0,
244-
}}
245-
>
246-
{value}
247-
</p>
240+
{!isValueWrappedInPre && (
241+
<p
242+
title={value}
243+
style={{
244+
...paraGraphDefaultStyle,
245+
margin: 0,
246+
padding: 0,
247+
}}
248+
>
249+
{value}
250+
</p>
251+
)}
252+
{isValueWrappedInPre && (
253+
<div
254+
style={{
255+
...paraGraphDefaultStyle,
256+
margin: 0,
257+
padding: 0,
258+
}}
259+
>
260+
{value}
261+
</div>
262+
)}
248263
</td>
249264
</tr>
250265
)}

0 commit comments

Comments
 (0)