Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix: Allow copy value as object (#299)

Kien Ngod9afeffbf18c
diff --git a/apps/start/src/components/ui/key-value-grid.tsx b/apps/start/src/components/ui/key-value-grid.tsx
index 54481274a..ea0fbd410 100644
--- a/apps/start/src/components/ui/key-value-grid.tsx
+++ b/apps/start/src/components/ui/key-value-grid.tsx
@@ -102,7 +102,18 @@ export function KeyValueGrid({
<button
onClick={(e) => {
e.stopPropagation();
- clipboard(item.value);
+ if (typeof item.value === 'object') {
+ try {
+ const value = JSON.stringify(item.value);
+ clipboard(value);
+ }
+ catch {
+ clipboard(item.value);
+ }
+ }
+ else {
+ clipboard(item.value);
+ }
}}
type="button"
className="absolute left-2 top-1/2 -translate-y-1/2 -translate-x-full opacity-0 group-hover:translate-x-0 group-hover:opacity-100 transition-all duration-200 ease-out bg-background border border-border rounded p-1 shadow-sm z-10"