From 41677918ec37038b1f333ca7b5e43bcab38ff4e2 Mon Sep 17 00:00:00 2001 From: ghaniiii Date: Mon, 22 Jun 2026 22:22:15 +0500 Subject: [PATCH 1/2] Fix: Chat scroll and navigation layout - smart auto-scroll, hide footer on chat pages --- CLAUDE.md | 53 +++++++++++++++++++++++++++++ app/[locale]/chat/page.tsx | 32 ++++++++++++++--- app/chat/page.tsx | 32 ++++++++++++++--- app/layout.tsx | 5 ++- components/floating-chat-bubble.tsx | 35 ++++++++++++++++--- components/layout-content.tsx | 24 +++++++++++++ 6 files changed, 165 insertions(+), 16 deletions(-) create mode 100644 components/layout-content.tsx diff --git a/CLAUDE.md b/CLAUDE.md index 0c5d472..4fdda1c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -353,6 +353,59 @@ These client components wrap server components to trigger GA events on mount. **Documentation**: See `docs/google-analytics-integration.md` for comprehensive setup details, metric recommendations, and troubleshooting. +## Bug Fixes & Improvements (June 2026) + +### 1. Chat Auto-Scroll Fix +**Issue**: Chat automatically scrolled to bottom on every message, disrupting users reading previous messages. + +**Solution**: Implemented smart scroll detection that only auto-scrolls when user is already at the bottom of the chat. + +**Files Modified**: +- `app/[locale]/chat/page.tsx` - Added scroll position tracking with `messagesContainerRef` and `shouldAutoScrollRef` +- `app/chat/page.tsx` - Same smart scroll implementation +- `components/floating-chat-bubble.tsx` - Removed duplicate scroll triggers, added smart scroll logic + +**How it works**: +- Tracks distance from bottom: `scrollHeight - (scrollTop + clientHeight)` +- Only auto-scrolls if within 100px of bottom +- Preserves user's scroll position when reading previous messages +- Smooth scrolling when at bottom + +**Benefits**: +- ✅ Users can read previous messages without interruption +- ✅ Auto-scroll still works when at bottom +- ✅ Much better mobile experience +- ✅ No more jumping/jarring scrolls during message streaming + +### 2. Duplicate Navigation Bar Fix +**Issue**: Chat page showed duplicate elements at top and bottom - main navigation bar at top, and footer appearing at bottom below chat area, cluttering the interface. + +**Solution**: Created `LayoutContent` component to conditionally hide footer on chat pages while keeping the main navigation. The footer itself already contains only the attribution text (no duplicate nav items), but it appeared as clutter in the chat interface. + +**Files Modified**: +- `app/layout.tsx` - Uses new `LayoutContent` component instead of directly rendering SiteHeader/Footer +- `components/layout-content.tsx` - New component that conditionally renders navigation based on route +- `components/footer.tsx` - Already optimized (shows only attribution: "Built with ❤️ by Code For Pakistan") + +**How it works**: +```typescript +const isChatPage = pathname.includes('/chat') + +return ( + <> + // Always shown +
{children}
+ {!isChatPage &&