From 5f3103db242413958cc89d74fc38719a30d06ffc Mon Sep 17 00:00:00 2001 From: Dhineshkumarprakasam Date: Wed, 3 Jun 2026 07:44:15 +0530 Subject: [PATCH] feature : Added scroll to top for lengthy response --- frontend/src/components/views/ScanResults.tsx | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/views/ScanResults.tsx b/frontend/src/components/views/ScanResults.tsx index 23b97e1..f85d059 100644 --- a/frontend/src/components/views/ScanResults.tsx +++ b/frontend/src/components/views/ScanResults.tsx @@ -1,6 +1,6 @@ 'use client'; import { useState, useEffect, useRef } from 'react'; -import { ExternalLink, Printer, Download, Shield, AlertTriangle, Globe, Server, Lock, User, Clock, Zap, Phone, MessageCircle, Map, GitBranch, Code, Brain, ChevronDown, ChevronUp, SendHorizontal, Mail, Copy, Eye, ShieldAlert } from 'lucide-react'; +import { ExternalLink, Printer, Download, Shield, AlertTriangle, Globe, Server, Lock, User, Clock, Zap, Phone, MessageCircle, Map, GitBranch, Code, Brain, ChevronDown, ChevronUp, SendHorizontal, Mail, Copy, Eye, ShieldAlert, ArrowUp } from 'lucide-react'; import type { ScanResults, ScanMeta, OpsecFinding } from '@/lib/types'; import { fetchReportBlob, generateAiSummary, sendAiChat, getMapData, getGraphData } from '@/lib/api'; import { useTranslations } from '@/lib/i18n'; @@ -312,9 +312,11 @@ export function ScanResults({ scan }: Props) { const [chatHistory, setChatHistory] = useState<{role:'user'|'ai'; text:string}[]>([]); const [chatLoading, setChatLoading] = useState(false); const [showJson, setShowJson] = useState(false); + const [showBackToTop, setShowBackToTop] = useState(false); const [copyToast, setCopyToast] = useState(''); const [reportLoading, setReportLoading] = useState<'html' | 'pdf' | null>(null); const toastTimerRef = useRef | null>(null); + const contentRef = useRef(null); const r = scan.results; const opsec = r.opsec; @@ -339,6 +341,15 @@ export function ScanResults({ scan }: Props) { if (toastTimerRef.current) clearTimeout(toastTimerRef.current); }, []); + useEffect(() => { + const host = contentRef.current; + if (!host) return; + const onScroll = () => setShowBackToTop(host.scrollTop > 300); + onScroll(); + host.addEventListener('scroll', onScroll, { passive: true }); + return () => host.removeEventListener('scroll', onScroll as EventListener); + }, []); + const sendChat = async () => { const msg = chatInput.trim(); if (!msg || chatLoading) return; @@ -493,7 +504,7 @@ export function ScanResults({ scan }: Props) { ))} -
+
{tab === 'findings' && (
@@ -1018,8 +1029,30 @@ export function ScanResults({ scan }: Props) {
)}
+ {showBackToTop && ( +
+ +
+
Back to top
+
+
+ )} + {copyToast && ( -
+
{copyToast}
)}