diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent/SystemSignaturesContent.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent/SystemSignaturesContent.tsx index 3cc4df48..0e3ea897 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent/SystemSignaturesContent.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/SystemSignaturesContent/SystemSignaturesContent.tsx @@ -84,7 +84,7 @@ export const SystemSignaturesContent = ({ const tooltipRef = useRef(null); - const { clipboardContent } = useClipboard(); + const { clipboardContent, setClipboardContent } = useClipboard(); const lazyDeleteValue = useMemo(() => { return settings.find(setting => setting.key === LAZY_DELETE_SIGNATURES_SETTING)?.value ?? false; @@ -205,6 +205,28 @@ export const SystemSignaturesContent = ({ [onSelect, selectable], ); + const handlePaste = async (clipboardContent: string) => { + const newSignatures = parseSignatures( + clipboardContent, + settings.map(x => x.key), + ); + + handleUpdateSignatures(newSignatures, !lazyDeleteValue); + }; + + const handleEnterRow = useCallback( + (e: DataTableRowMouseEvent) => { + setHoveredSig(filteredSignatures[e.index]); + tooltipRef.current?.show(e.originalEvent); + }, + [filteredSignatures], + ); + + const handleLeaveRow = useCallback((e: DataTableRowMouseEvent) => { + tooltipRef.current?.hide(e.originalEvent); + setHoveredSig(null); + }, []); + useEffect(() => { if (refData.current.selectable) { return; @@ -215,17 +237,9 @@ export const SystemSignaturesContent = ({ } handlePaste(clipboardContent.text); + setClipboardContent(null); }, [clipboardContent, selectable, lazyDeleteValue]); - const handlePaste = async (clipboardContent: string) => { - const newSignatures = parseSignatures( - clipboardContent, - settings.map(x => x.key), - ); - - handleUpdateSignatures(newSignatures, !lazyDeleteValue); - }; - useHotkey(true, ['a'], handleSelectAll); useHotkey(false, ['Backspace', 'Delete'], handleDeleteSelected); @@ -265,19 +279,6 @@ export const SystemSignaturesContent = ({ }; }, []); - const handleEnterRow = useCallback( - (e: DataTableRowMouseEvent) => { - setHoveredSig(filteredSignatures[e.index]); - tooltipRef.current?.show(e.originalEvent); - }, - [filteredSignatures], - ); - - const handleLeaveRow = useCallback((e: DataTableRowMouseEvent) => { - tooltipRef.current?.hide(e.originalEvent); - setHoveredSig(null); - }, []); - const renderToolbar = (/*row: SystemSignature*/) => { return (
diff --git a/assets/js/hooks/Mapper/hooks/useClipboard.ts b/assets/js/hooks/Mapper/hooks/useClipboard.ts index 604ddff7..ebe4effd 100644 --- a/assets/js/hooks/Mapper/hooks/useClipboard.ts +++ b/assets/js/hooks/Mapper/hooks/useClipboard.ts @@ -30,5 +30,5 @@ export const useClipboard = () => { }; }, []); - return { clipboardContent, error, getClipboardContent }; + return { clipboardContent, error, getClipboardContent, setClipboardContent }; };