From 7bd86945951d27cbf08283c2fca64534e20a365b Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Sat, 13 Dec 2025 12:07:08 +0100 Subject: [PATCH] Update FieldHistoryModal and clipboard countdown bar (#1404) --- .../components/ClipboardCountdownBar.tsx | 2 +- .../Credentials/Details/FieldBlock.tsx | 82 +++----------- .../Credentials/Details/FieldHistoryModal.tsx | 102 +++++------------- .../Forms/FormInputCopyToClipboard.tsx | 5 +- 4 files changed, 45 insertions(+), 146 deletions(-) diff --git a/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsx b/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsx index 4f0934998..e6cbcdfb9 100644 --- a/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsx +++ b/apps/browser-extension/src/entrypoints/popup/components/ClipboardCountdownBar.tsx @@ -97,7 +97,7 @@ export const ClipboardCountdownBar: React.FC = () => { } return ( -
+
= ({ field, itemId }) => { case 'Hidden': return ( <> -
- -
- -
- -
-
-
+ {HistoryModal} ); @@ -179,40 +152,13 @@ const FieldBlock: React.FC = ({ field, itemId }) => { default: return ( <> -
- -
- -
- -
-
-
+ {HistoryModal} ); diff --git a/apps/browser-extension/src/entrypoints/popup/components/Credentials/Details/FieldHistoryModal.tsx b/apps/browser-extension/src/entrypoints/popup/components/Credentials/Details/FieldHistoryModal.tsx index 55a6058b8..b3af85e37 100644 --- a/apps/browser-extension/src/entrypoints/popup/components/Credentials/Details/FieldHistoryModal.tsx +++ b/apps/browser-extension/src/entrypoints/popup/components/Credentials/Details/FieldHistoryModal.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { useTranslation } from 'react-i18next'; +import { FormInputCopyToClipboard } from '@/entrypoints/popup/components/Forms/FormInputCopyToClipboard'; import { useDb } from '@/entrypoints/popup/context/DbContext'; import type { FieldHistory, FieldType } from '@/utils/dist/core/models/vault'; @@ -33,7 +34,6 @@ const FieldHistoryModal: React.FC = ({ const { t } = useTranslation(); const dbContext = useDb(); const [history, setHistory] = useState([]); - const [visibleValues, setVisibleValues] = useState>(new Set()); const [loading, setLoading] = useState(true); // For non-hidden fields, show values by default @@ -59,32 +59,6 @@ const FieldHistoryModal: React.FC = ({ return null; } - /** - * Toggle the visibility of a field value in the history modal. - */ - const toggleValueVisibility = (historyId: string): void => { - setVisibleValues(prev => { - const newSet = new Set(prev); - if (newSet.has(historyId)) { - newSet.delete(historyId); - } else { - newSet.add(historyId); - } - return newSet; - }); - }; - - /** - * Copy a field value to the clipboard. - */ - const copyToClipboard = async (value: string): Promise => { - try { - await navigator.clipboard.writeText(value); - } catch (error) { - console.error('Failed to copy to clipboard:', error); - } - }; - /** * Format a date string to a human readable format. */ @@ -114,13 +88,26 @@ const FieldHistoryModal: React.FC = ({ } }; + /** + * Handle click on backdrop to close modal. + */ + const handleBackdropClick = (e: React.MouseEvent): void => { + // Only close if clicking directly on the backdrop/container, not the modal content + if (e.target === e.currentTarget) { + onClose(); + } + }; + return (
{/* Backdrop */}
- {/* Modal */} -
+ {/* Modal container - clicking here (outside modal content) closes */} +
{/* Header */}
@@ -153,50 +140,24 @@ const FieldHistoryModal: React.FC = ({
{history.map((record) => { const values = parseValueSnapshot(record.ValueSnapshot); - /** - * For hidden fields, check if this record is explicitly set to visible - * For non-hidden fields, always show values (no toggle needed) - */ - const isVisible = shouldMaskByDefault ? visibleValues.has(record.Id) : true; return (
-
-
- {formatDate(record.ChangedAt)} -
- {shouldMaskByDefault && ( - - )} +
+ {formatDate(record.ChangedAt)}
{values.map((value, idx) => ( -
-
- {shouldMaskByDefault && !isVisible ? '\u2022'.repeat(12) : value} -
- +
+
))}
@@ -205,17 +166,6 @@ const FieldHistoryModal: React.FC = ({
)}
- - {/* Footer */} -
- -
diff --git a/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsx b/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsx index 2be4cc21a..d111304c0 100644 --- a/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsx +++ b/apps/browser-extension/src/entrypoints/popup/components/Forms/FormInputCopyToClipboard.tsx @@ -12,6 +12,7 @@ type FormInputCopyToClipboardProps = { label: string; value: string; type?: 'text' | 'password'; + labelSuffix?: React.ReactNode; } const clipboardService = new ClipboardCopyService(); @@ -60,7 +61,8 @@ export const FormInputCopyToClipboard: React.FC = id, label, value, - type = 'text' + type = 'text', + labelSuffix }) => { const { t } = useTranslation(); const [showPassword, setShowPassword] = useState(false); @@ -101,6 +103,7 @@ export const FormInputCopyToClipboard: React.FC =