From 2ab23187322e41dc2e7feaf207155ae02b602f71 Mon Sep 17 00:00:00 2001 From: devops Date: Sat, 17 Oct 2026 10:29:51 +0000 Subject: [PATCH] fix(ux): render mobile solution and symptom modals via React Portal to prevent CSS mask clipping --- .../application/components/ArchivePage.tsx | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/frontend/application/components/ArchivePage.tsx b/frontend/application/components/ArchivePage.tsx index 577cde51..053320ec 100644 --- a/frontend/application/components/ArchivePage.tsx +++ b/frontend/application/components/ArchivePage.tsx @@ -1,5 +1,6 @@ "use client"; import React, { useState, useMemo, useEffect, useCallback } from "react"; +import { createPortal } from "react-dom"; import { toPersian, isProductOutOfStock } from "../lib/utils"; import { Product, PetType } from "../lib/data/products"; import { usePetStore } from "../lib/store/usePetStore"; @@ -470,6 +471,11 @@ export default function ArchivePage({ const [sortOrder, setSortOrder] = useState<"asc" | "desc">("desc"); const [viewMode, setViewMode] = useState<"list" | "grid">("list"); const [visibleCount, setVisibleCount] = useState(12); + const [isMounted, setIsMounted] = useState(false); + + useEffect(() => { + setIsMounted(true); + }, []); const [isMobileSolutionsOpen, setIsMobileSolutionsOpen] = useState(false); const [isMobileSymptomsOpen, setIsMobileSymptomsOpen] = useState(false); @@ -919,8 +925,8 @@ export default function ArchivePage({ - {isMobileSolutionsOpen && ( -
setIsMobileSolutionsOpen(false)}> + {isMobileSolutionsOpen && isMounted && createPortal( +
setIsMobileSolutionsOpen(false)}>
e.stopPropagation()} @@ -931,7 +937,7 @@ export default function ArchivePage({ @@ -945,7 +951,7 @@ export default function ArchivePage({ setSelectedCategory(cat.id); setIsMobileSolutionsOpen(false); }} - className={`w-full flex items-center gap-3 px-4 py-3 rounded-2xl text-xs font-bold text-right transition-colors border ${selectedCategory === cat.id ? "bg-canina-blue border-canina-blue text-white" : "bg-white border-medical-gray-100 hover:bg-medical-gray-50 text-medical-gray-700"}`} + className={`w-full flex items-center gap-3 px-4 py-3 rounded-2xl text-xs font-bold text-right transition-colors border cursor-pointer ${selectedCategory === cat.id ? "bg-canina-blue border-canina-blue text-white" : "bg-white border-medical-gray-100 hover:bg-medical-gray-50 text-medical-gray-700"}`} > {cat.icon} {cat.label} @@ -953,7 +959,8 @@ export default function ArchivePage({ ))}
-
+ , + document.body )} @@ -971,8 +978,8 @@ export default function ArchivePage({ - {isMobileSymptomsOpen && ( -
setIsMobileSymptomsOpen(false)}> + {isMobileSymptomsOpen && isMounted && createPortal( +
setIsMobileSymptomsOpen(false)}>
e.stopPropagation()} @@ -988,7 +995,7 @@ export default function ArchivePage({ @@ -996,7 +1003,7 @@ export default function ArchivePage({ @@ -1026,7 +1033,7 @@ export default function ArchivePage({ key={s} type="button" onClick={() => toggleSymptom(s)} - className={`px-3 py-1.5 rounded-xl text-xs font-bold transition-all border whitespace-nowrap ${activeSymptoms.includes(s) + className={`px-3 py-1.5 rounded-xl text-xs font-bold transition-all border whitespace-nowrap cursor-pointer ${activeSymptoms.includes(s) ? "bg-canina-blue border-canina-blue text-white shadow-2xs" : "bg-medical-gray-50 border-medical-gray-200 text-medical-gray-600 hover:border-canina-blue/40 hover:text-canina-blue" }`} @@ -1041,13 +1048,14 @@ export default function ArchivePage({
-
+ , + document.body )}