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

fix: OPTIC-152: Uploading a text field but only 'true' is showing up not 'false' #294

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/CellViews/StringCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ const valueToString = (value) => {
try {
return JSON.stringify(value);
} catch {
return value.toString();
/* if undefined or null we'll treat it as empty string, otherwise toString(), this will allow 0 and false to render properly */
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.

the same comment as in #295:

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

the issue with false and 0 is fully fixed by next change. but most probably it won't work as expected if you want to return empty string for null and undefined, then you have to check for them specifically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I applied a change based on our discussion. i also added a unit test in LS PR

}
};

Expand All @@ -18,7 +19,7 @@ export const StringCell = ({ value }) => {
lineHeight: "16px",
}}
>
{value ? valueToString(value) : ""}
{valueToString(value)}
</div>
);
};
Loading