[fix] negosium·negodata·landing: 채팅 진입·부가정보 저장 오류 수정, 모바일 여백·스크롤·노치 대응
- 채팅 링크로 바로 진입하면 세션이 협상생성(1)에 머물러 오프닝 메시지가 seed 되지 않던 문제: chat init/messages 에서 participate 와 동일하게 협상중(2)으로 전이(마감 견적·마감시간 초과는 제외) - 부가정보 저장이 1301 로 실패하던 문제: '협상완료' 요약은 chat_end=false 라 세션이 아직 협상중이므로, 마지막 말풍선이 summaryRSP/CM 이면 협상중 세션도 저장 허용 - 채팅 언마운트 시 messages 캐시도 제거 — staleTime:Infinity 라 빈 목록이 남아 재진입해도 빈 화면이던 문제 - 채팅 스크롤을 컨테이너 기준 scrollTo 로 변경(rAF 후 실행) — 요약·폼이 뒤늦게 레이아웃되면 중간에 멈추던 문제 - 모바일 채팅 상단 여백 제거(pt-[64px] 는 우측 협상절차 카드가 있는 lg 이상만) - 노치 대응: viewport-fit=cover + safe-t/b/x 유틸 신설, 헤더·하단 액션 덱·드로어·랜딩 헤더에 적용, h-screen→100dvh
This commit is contained in:
1 parent
0f10b6a70f
commit
db07a60cfa
16 files changed
+144
-30
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useRef, memo } from 'react'
|
||||
import { useEffect, useRef, memo, type RefObject } from 'react'
|
||||
import { useMeQuery } from '@/apis'
|
||||
import { useChatStore } from '@/features/chat/stores/useChatStore'
|
||||
import { useChatInitStore } from '@/features/chat/stores/useChatInitStore'
|
||||
@@ -14,24 +14,40 @@ import { RejectCM } from '@/features/chat/components/templates/RejectCM'
|
||||
const AI_LABEL = '아이마켓코리아 (구매 MD)'
|
||||
|
||||
export function ChatMessage() {
|
||||
const scrollRef = useRef<HTMLDivElement | null>(null)
|
||||
return (
|
||||
<div className="flex-1 w-full min-h-0">
|
||||
{/* pt-[64px]: 첫 메시지를 우측 협상절차 카드 상단과 맞추되, 스크롤 시 여백도 함께 밀려 올라가도록 스크롤 컨테이너 안쪽에 둔다 */}
|
||||
<div className="chat-scroll h-full overflow-y-auto flex flex-col pt-[64px] pb-6 px-4 sm:px-6 min-[1180px]:pl-[80px] min-[1180px]:pr-[72px] min-[1350px]:pl-[140px] min-[1350px]:pr-[126px]">
|
||||
<ChatList />
|
||||
{/* lg:pt-[64px]: 첫 메시지를 우측 협상절차 카드 상단과 맞추는 값 — 그 카드가 없는 lg 미만에선
|
||||
스텝바 바로 아래 여백으로만 남아 첫 메시지가 위로 안 붙으므로 뺀다.
|
||||
스크롤 시 여백도 함께 밀려 올라가도록 스크롤 컨테이너 안쪽에 둔다 */}
|
||||
<div
|
||||
ref={scrollRef}
|
||||
className="chat-scroll h-full overflow-y-auto flex flex-col pt-4 lg:pt-[64px] pb-6 px-4 sm:px-6 min-[1180px]:pl-[80px] min-[1180px]:pr-[72px] min-[1350px]:pl-[140px] min-[1350px]:pr-[126px]"
|
||||
>
|
||||
<ChatList scrollRef={scrollRef} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ChatList() {
|
||||
const bottomRef = useRef<HTMLDivElement | null>(null)
|
||||
function ChatList({ scrollRef }: { scrollRef: RefObject<HTMLDivElement | null> }) {
|
||||
const isFirstRef = useRef(true)
|
||||
const chats = useChatStore((s) => s.messages)
|
||||
const isLoading = useChatStore((s) => s.isLoading)
|
||||
|
||||
// 메시지 추가/타이핑 표시 시 항상 맨 아래로 스크롤
|
||||
// 메시지 추가/타이핑 표시 시 항상 맨 아래로 스크롤.
|
||||
// 스크롤 컨테이너를 직접 내린다 — scrollIntoView 는 요약/부가정보 폼처럼 큰 블록이 뒤늦게
|
||||
// 레이아웃되면 애니메이션 도중 목표 위치가 밀려 중간에 멈춘다.
|
||||
// 진입 첫 렌더는 즉시(auto) — 히스토리를 복원하며 위에서부터 훑어 내려가는 연출을 막는다.
|
||||
useEffect(() => {
|
||||
bottomRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||
const scroller = scrollRef.current
|
||||
if (!scroller) return
|
||||
const behavior: ScrollBehavior = isFirstRef.current ? 'auto' : 'smooth'
|
||||
isFirstRef.current = false
|
||||
const id = requestAnimationFrame(() => {
|
||||
scroller.scrollTo({ top: scroller.scrollHeight, behavior })
|
||||
})
|
||||
return () => cancelAnimationFrame(id)
|
||||
}, [chats, isLoading])
|
||||
|
||||
if (!chats || chats.length === 0) {
|
||||
@@ -48,7 +64,6 @@ function ChatList() {
|
||||
<MessageItem key={message.chat_id || index} message={message} messages={chats} currentIndex={index} />
|
||||
))}
|
||||
{isLoading && <TypingBubble />}
|
||||
<div ref={bottomRef} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ export function ChatSection() {
|
||||
<MobileStepBar />
|
||||
<ChatMessage />
|
||||
{/* 하단 액션 덱 */}
|
||||
<div className="shrink-0 border-t border-border bg-white shadow-[0_-4px_20px_rgba(0,0,0,0.03)]">
|
||||
{/* safe-b: 홈 인디케이터에 입력 버튼이 가리지 않도록 하단 안전영역 확보 */}
|
||||
<div className="shrink-0 safe-b border-t border-border bg-white shadow-[0_-4px_20px_rgba(0,0,0,0.03)]">
|
||||
<UserButton {...userButtonConfig} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -31,7 +31,7 @@ export function MobileDrawer({ open, onClose, side = 'left', title, children }:
|
||||
side === 'left' ? 'left-0' : 'right-0',
|
||||
)}
|
||||
>
|
||||
<div className="flex h-14 shrink-0 items-center justify-between border-b border-border px-5">
|
||||
<div className="flex h-14 box-content safe-t shrink-0 items-center justify-between border-b border-border px-5">
|
||||
<span className="text-base font-bold text-neutral-90">{title}</span>
|
||||
<button
|
||||
type="button"
|
||||
@@ -42,7 +42,7 @@ export function MobileDrawer({ open, onClose, side = 'left', title, children }:
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto">{children}</div>
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto safe-b">{children}</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body,
|
||||
|
||||
Reference in new issue
Block a user