fix(ux): render mobile solution and symptom modals via React Portal to prevent CSS mask clipping
Deploy Canina / deploy (push) Successful in 2m10s
Deploy Canina / deploy (push) Successful in 2m10s
This commit is contained in:
1 parent
f3806cd6de
commit
2ab2318732
1 file changed
+20
-12
@@ -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<number>(12);
|
||||
const [isMounted, setIsMounted] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
setIsMounted(true);
|
||||
}, []);
|
||||
const [isMobileSolutionsOpen, setIsMobileSolutionsOpen] = useState(false);
|
||||
const [isMobileSymptomsOpen, setIsMobileSymptomsOpen] = useState(false);
|
||||
|
||||
@@ -919,8 +925,8 @@ export default function ArchivePage({
|
||||
<ChevronDown className={`w-3 h-3 transition-transform ${isMobileSolutionsOpen ? "rotate-180" : ""}`} />
|
||||
</button>
|
||||
|
||||
{isMobileSolutionsOpen && (
|
||||
<div className="fixed inset-0 z-50 flex items-end justify-center bg-black/40 backdrop-blur-xs font-vazir" onClick={() => setIsMobileSolutionsOpen(false)}>
|
||||
{isMobileSolutionsOpen && isMounted && createPortal(
|
||||
<div className="fixed inset-0 z-[9999] flex items-end justify-center bg-black/50 backdrop-blur-xs font-vazir" dir="rtl" onClick={() => setIsMobileSolutionsOpen(false)}>
|
||||
<div
|
||||
className="w-full max-w-lg bg-white rounded-t-3xl p-5 border-t border-medical-gray-200 shadow-2xl max-h-[75vh] flex flex-col animate-in slide-in-from-bottom duration-200"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
@@ -931,7 +937,7 @@ export default function ArchivePage({
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMobileSolutionsOpen(false)}
|
||||
className="text-xs text-medical-gray-400 hover:text-medical-gray-700 font-bold p-1"
|
||||
className="text-xs text-medical-gray-400 hover:text-medical-gray-700 font-bold p-1 cursor-pointer"
|
||||
>
|
||||
بستن ✕
|
||||
</button>
|
||||
@@ -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"}`}
|
||||
>
|
||||
<span className="shrink-0">{cat.icon}</span>
|
||||
<span className="truncate">{cat.label}</span>
|
||||
@@ -953,7 +959,8 @@ export default function ArchivePage({
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -971,8 +978,8 @@ export default function ArchivePage({
|
||||
<ChevronDown className={`w-3 h-3 transition-transform ${isMobileSymptomsOpen ? "rotate-180" : ""}`} />
|
||||
</button>
|
||||
|
||||
{isMobileSymptomsOpen && (
|
||||
<div className="fixed inset-0 z-50 flex items-end justify-center bg-black/40 backdrop-blur-xs font-vazir" onClick={() => setIsMobileSymptomsOpen(false)}>
|
||||
{isMobileSymptomsOpen && isMounted && createPortal(
|
||||
<div className="fixed inset-0 z-[9999] flex items-end justify-center bg-black/50 backdrop-blur-xs font-vazir" dir="rtl" onClick={() => setIsMobileSymptomsOpen(false)}>
|
||||
<div
|
||||
className="w-full max-w-lg bg-white rounded-t-3xl p-5 border-t border-medical-gray-200 shadow-2xl max-h-[80vh] flex flex-col animate-in slide-in-from-bottom duration-200"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
@@ -988,7 +995,7 @@ export default function ArchivePage({
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveSymptoms([])}
|
||||
className="text-xs font-bold text-red-500 hover:underline px-1"
|
||||
className="text-xs font-bold text-red-500 hover:underline px-1 cursor-pointer"
|
||||
>
|
||||
پاک کردن همه
|
||||
</button>
|
||||
@@ -996,7 +1003,7 @@ export default function ArchivePage({
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMobileSymptomsOpen(false)}
|
||||
className="text-xs text-medical-gray-400 hover:text-medical-gray-700 font-bold p-1"
|
||||
className="text-xs text-medical-gray-400 hover:text-medical-gray-700 font-bold p-1 cursor-pointer"
|
||||
>
|
||||
بستن ✕
|
||||
</button>
|
||||
@@ -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({
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsMobileSymptomsOpen(false)}
|
||||
className="w-full bg-canina-blue text-white py-2.5 rounded-xl font-bold text-xs shadow-lg shadow-canina-blue/20"
|
||||
className="w-full bg-canina-blue text-white py-2.5 rounded-xl font-bold text-xs shadow-lg shadow-canina-blue/20 cursor-pointer"
|
||||
>
|
||||
مشاهده نتایج {activeSymptoms.length > 0 ? `(${toPersian(activeSymptoms.length)} علامت)` : ""}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user