From e575733579472b2e6b83105074009b99365fab4b Mon Sep 17 00:00:00 2001 From: mortezaei Date: Mon, 31 Aug 2026 00:40:51 +0330 Subject: [PATCH] fix: improve keyboard interaction reliability, add SSR debugging logs, and resolve DiscountWidget initialization in subscription sheet --- src/app/layout.tsx | 20 +++++++++++- src/app/new-match/new-match-client.tsx | 2 +- src/app/providers.tsx | 10 ++++++ .../request-accepted-client.tsx | 1 + .../Componentes/discount-widget.tsx | 6 ---- .../Componentes/information-sheet.test.tsx | 31 +++++++++++++++++++ .../Componentes/information-sheet.tsx | 12 ++----- .../subscription-required-sheet.tsx | 12 +++---- src/hooks/marriage/use-profile-main.ts | 6 ++-- 9 files changed, 72 insertions(+), 28 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 364f374..98c21d6 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -61,13 +61,31 @@ export default async function RootLayout({ const parsed = JSON.parse(decoded); initialMarriageJson = decoded; initialProfile = getInitialMarriageProfile(parsed); + console.log("🖥️ [SSR Layout] Parsed rawMarriageCookie successfully:", { + status: initialProfile?.status, + gender: initialProfile?.gender, + has_match_summary: Boolean(initialProfile?.match_summary), + match_summary_id: initialProfile?.match_summary?.id, + public_info_count: initialProfile?.match_summary?.public_info?.length, + }); } catch { try { const parsed = JSON.parse(rawMarriageCookie); initialMarriageJson = rawMarriageCookie; initialProfile = getInitialMarriageProfile(parsed); - } catch {} + console.log("🖥️ [SSR Layout] Parsed rawMarriageCookie (non-decoded) successfully:", { + status: initialProfile?.status, + gender: initialProfile?.gender, + has_match_summary: Boolean(initialProfile?.match_summary), + match_summary_id: initialProfile?.match_summary?.id, + public_info_count: initialProfile?.match_summary?.public_info?.length, + }); + } catch (e) { + console.warn("🖥️ [SSR Layout] Failed to parse rawMarriageCookie:", e); + } } + } else { + console.log("🖥️ [SSR Layout] No rawMarriageCookie found in request cookies"); } return ( diff --git a/src/app/new-match/new-match-client.tsx b/src/app/new-match/new-match-client.tsx index 89ad7cb..dd57331 100644 --- a/src/app/new-match/new-match-client.tsx +++ b/src/app/new-match/new-match-client.tsx @@ -738,7 +738,7 @@ export default function NewMatchClient() { {/* 2. Match Summary Card Section */} -
+
{(isLoading || (!matchSummary && isFetching)) ? (
diff --git a/src/app/providers.tsx b/src/app/providers.tsx index e5a8d84..0963f7f 100644 --- a/src/app/providers.tsx +++ b/src/app/providers.tsx @@ -44,7 +44,17 @@ export default function Providers({ children, initialProfile }: ProvidersProps) }, }); if (initialProfile) { + console.log("⚡ [Providers] Initializing QueryClient cache with SSR initialProfile:", { + id: initialProfile.id, + status: initialProfile.status, + gender: initialProfile.gender, + has_match_summary: Boolean(initialProfile.match_summary), + match_summary_id: initialProfile.match_summary?.id, + public_info_count: initialProfile.match_summary?.public_info?.length, + }); qc.setQueryData(marriageQueryKeys.profile(), initialProfile); + } else { + console.log("ℹ️ [Providers] No initialProfile passed from SSR"); } return qc; }, diff --git a/src/app/request-accepted/request-accepted-client.tsx b/src/app/request-accepted/request-accepted-client.tsx index a345e85..5998b51 100644 --- a/src/app/request-accepted/request-accepted-client.tsx +++ b/src/app/request-accepted/request-accepted-client.tsx @@ -572,6 +572,7 @@ export default function RequestAcceptedClient() { setPaymentError(null); setIsInsufficientCoins(false); }} + planId={recommendedPlanId} onPayment={handlePayment} isPaymentPending={!recommendedPlanId || paymentMutation.isPending} errorMessage={paymentError} diff --git a/src/components/Componentes/discount-widget.tsx b/src/components/Componentes/discount-widget.tsx index c91b116..e35e1d2 100644 --- a/src/components/Componentes/discount-widget.tsx +++ b/src/components/Componentes/discount-widget.tsx @@ -157,12 +157,6 @@ export function DiscountWidget({ dir="auto" value={code} disabled={discountStatus === "loading" || discountResult !== null} - onFocus={(e) => { - const target = e.target; - setTimeout(() => { - target.scrollIntoView({ behavior: "smooth", block: "center" }); - }, 150); - }} onChange={(e) => { setCode(e.target.value); if (discountStatus !== "initial") { diff --git a/src/components/Componentes/information-sheet.test.tsx b/src/components/Componentes/information-sheet.test.tsx index e58840a..e0f0c0d 100644 --- a/src/components/Componentes/information-sheet.test.tsx +++ b/src/components/Componentes/information-sheet.test.tsx @@ -100,5 +100,36 @@ describe("InformationSheet", () => { expect(section?.style.paddingBottom).toBe(""); }); }); + + it("should immediately reset keyboard lift when input loses focus (focusOut)", async () => { + render( + + +
+ } + />, + ); + + const input = screen.getByTestId("test-input-blur"); + const section = document.querySelector("section"); + + input.focus(); + fireEvent.focusIn(input); + + await waitFor(() => { + expect(section?.style.paddingBottom).not.toBe(""); + }); + + input.blur(); + fireEvent.focusOut(input); + + await waitFor(() => { + expect(section?.style.paddingBottom).toBe(""); + }); + }); }); diff --git a/src/components/Componentes/information-sheet.tsx b/src/components/Componentes/information-sheet.tsx index 2c4a411..c5a9af9 100644 --- a/src/components/Componentes/information-sheet.tsx +++ b/src/components/Componentes/information-sheet.tsx @@ -360,14 +360,6 @@ export function InformationSheet({ : getDefaultKeyboardHeight(); keyboardHeight = Math.max(keyboardHeight, expectedHeight); setLift(keyboardHeight); - setTimeout(() => { - if (typeof (e.target as any)?.scrollIntoView === "function") { - (e.target as any).scrollIntoView({ - behavior: "smooth", - block: "nearest", - }); - } - }, 100); } }; @@ -378,7 +370,7 @@ export function InformationSheet({ sheetRef.current?.contains(active) && isKeyboardInputTarget(active) ? (active as HTMLElement) : null; - if (!activeInput && (viewPaddingsBridge.getConfig().keyboardHeight || 0) === 0) { + if (!activeInput) { keyboardVisible = false; keyboardHeight = 0; setLift(0); @@ -445,7 +437,7 @@ export function InformationSheet({ const content = (
(
- {planId ? ( - setAppliedDiscount(res)} - onDiscountCleared={() => setAppliedDiscount(null)} - /> - ) : null} + setAppliedDiscount(res)} + onDiscountCleared={() => setAppliedDiscount(null)} + /> {errorMessage && (
diff --git a/src/hooks/marriage/use-profile-main.ts b/src/hooks/marriage/use-profile-main.ts index 40b42da..041f5d5 100644 --- a/src/hooks/marriage/use-profile-main.ts +++ b/src/hooks/marriage/use-profile-main.ts @@ -40,13 +40,13 @@ export function getInitialMarriageProfile( persistedPublicInfoCount: persisted?.match_summary?.public_info?.length, }); - // Priority 1: If Flutter provided match_summary (e.g. fresh match on new/current device) and persisted doesn't have it, prefer Flutter data - if (flutterData?.match_summary && !persisted?.match_summary) { + // Priority 1: If Flutter provided match_summary (e.g. active match from user/me), ALWAYS prefer Flutter data + if (flutterData?.match_summary) { console.log("⚡ [getInitialMarriageProfile] Using Flutter initial data (has match_summary)"); return { ...flutterData, id: flutterData.id || persisted?.id || 0, - status: flutterData.status || persisted?.status || "match_found", + status: flutterData.status || persisted?.status || "in_case", }; }