Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

fix: OPTIC-108: Text on grid view should be truncated #295

Merged
merged 7 commits into from
Jan 31, 2024
4 changes: 2 additions & 2 deletions src/components/DataGroups/AudioDataGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { MediaPlayer } from "../Common/MediaPlayer/MediaPlayer";

export const AudioDataGroup = ({ value }) => {
return (
<div style={{ padding: 10, height: AudioDataGroup.height }}>
<div style={{ padding: 10, height: AudioDataGroup.height, boxSizing: "content-box" }}>
<MediaPlayer src={value} />
</div>
);
};

AudioDataGroup.height = 42;
AudioDataGroup.height = 32;
20 changes: 13 additions & 7 deletions src/components/DataGroups/TextDataGroup.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { Tooltip } from "../Common/Tooltip/Tooltip";

const valueToString = (value) => {
if (typeof value === "string") return value;

try {
return JSON.stringify(value);
} catch {
return value.toString();
return (value ?? "").toString();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind of value could be here? it won't fail on null or undefined and that's the only values triggering nullish coalescing.

Copy link
Contributor Author

@yyassi-heartex yyassi-heartex Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be any non-JSON value - in this case null and undefined should render as "", while 0 and false should render as "0" and "false", every thing else should render as what ever it is, be it string, int, etc

}
};

export const TextDataGroup = ({ value }) => {
const output = valueToString(value);

return (
<div
style={{ padding: 5, height: TextDataGroup.height, overflow: "hidden" }}
>
{value ? valueToString(value) : ""}
</div>
<Tooltip title={output}>
<div
style={{ padding: 5, height: TextDataGroup.height, overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to const as well

>
{output}
</div>
</Tooltip>
);
};

TextDataGroup.height = 77;
TextDataGroup.height = 32;
Loading