Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions src/components/ResultsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const ResultRow = ({
const value = toCellValue({
value: r[`${key}-display`] || r[key] || "",
uid: (r[`${key}-uid`] as string) || "",
stripRefs: true,
});
const action = r[`${key}-action`];
if (typeof action === "string") {
Expand Down
13 changes: 12 additions & 1 deletion src/utils/toCellValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ const toCellValue = ({
value,
uid,
defaultValue = "",
stripRefs = false,
}: {
value: number | Date | string;
defaultValue?: string;
uid: string;
stripRefs?: boolean;
}) => {
const initialValue =
value instanceof Date
Expand All @@ -62,7 +64,16 @@ const toCellValue = ({
.join("/")
: initialValue
: initialValue;
return formattedValue;

// `extractTag` only unwraps a single, whole-string tag, so a multi-value
// attribute (e.g. `[[A]], [[B]]`) keeps its `[[ ]]` while a single value is
// unwrapped. When rendering for display, strip the page-ref delimiters from
// every remaining ref so multi-value cells read the same as single-value
// ones. Off by default so callers relying on the raw value (filtering,
// in-place edits) are unaffected.
return stripRefs
? formattedValue.replace(/#?\[\[([^[\]]+)\]\]/g, "$1")
: formattedValue;
};

export default toCellValue;