Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,12 @@ export function Chat({ id }: ChatProps) {
if (isMobile) {
return (
<MapDataProvider> {/* Add Provider */}
{/* The order of components here is critical for mobile layout.
Using a flex column, the .mobile-chat-messages-area is set to flex: 1
which allows it to take up the remaining space. The other components
have fixed heights, so for the chat area to scroll properly, it must
be rendered before the fixed-height elements. */}
Comment on lines +78 to +82
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Relying on DOM order to make the flex item scroll is fragile. A more robust approach is to ensure the flex parent allows its child to shrink and scroll by setting min-height: 0 on the flex container and ensuring the scrollable area has overflow-y: auto. This reduces coupling to DOM order and prevents regressions if fixed-height assumptions change.

Suggestion

Consider codifying the scroll behavior via styles so it doesn’t depend on DOM order:

  • Add minHeight: 0 to the flex container.
  • Ensure the messages area has overflowY: 'auto' (and keep flex: 1).

Example:

<div className="mobile-layout-container" style={{ minHeight: 0 }}>
  <div className="mobile-chat-messages-area" style={{ minHeight: 0, overflowY: 'auto' }}>
    {/* ... */}
  </div>
  {/* ... */}
</div>

Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion

<div className="mobile-layout-container">
<div className="mobile-map-section">
{activeView ? <SettingsView /> : <Mapbox />}
</div>
<div className="mobile-icons-bar">
<MobileIconsBar />
</div>
<div className="mobile-chat-input-area">
<ChatPanel messages={messages} input={input} setInput={setInput} />
</div>
<div className="mobile-chat-messages-area">
{showEmptyScreen ? (
<EmptyScreen
Expand All @@ -96,6 +92,15 @@ export function Chat({ id }: ChatProps) {
<ChatMessages messages={messages} />
)}
</div>
<div className="mobile-chat-input-area">
<ChatPanel messages={messages} input={input} setInput={setInput} />
</div>
<div className="mobile-icons-bar">
<MobileIconsBar />
</div>
<div className="mobile-map-section">
{activeView ? <SettingsView /> : <Mapbox />}
</div>
</div>
</MapDataProvider>
);
Expand Down