Skip to content

Commit

Permalink
add copy support to id
Browse files Browse the repository at this point in the history
  • Loading branch information
shamsmosowi committed Sep 3, 2023
1 parent 4a84523 commit a2806a7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/Table/useMenuAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const SUPPORTED_TYPES_COPY = new Set([
FieldType.updatedAt,
// CONNECTION
FieldType.reference,
FieldType.id,
]);

export const SUPPORTED_TYPES_PASTE = new Set([
Expand Down Expand Up @@ -98,7 +99,16 @@ export function useMenuAction(

const handleCopy = useCallback(async () => {
try {
if (cellValue !== undefined && cellValue !== null && cellValue !== "") {
if (selectedCol?.type === FieldType.id && selectedCell?.path) {
await navigator.clipboard.writeText(
selectedCell?.path.split("/").pop() || ""
);
enqueueSnackbar("Copied");
} else if (
cellValue !== undefined &&
cellValue !== null &&
cellValue !== ""
) {
const value = getValue(cellValue);
await navigator.clipboard.writeText(value);
enqueueSnackbar("Copied");
Expand Down

0 comments on commit a2806a7

Please sign in to comment.