From cd644d339cd8a464ff558be37d22be58bc7a1aaa Mon Sep 17 00:00:00 2001 From: dwindown Date: Thu, 6 Nov 2025 10:37:11 +0700 Subject: [PATCH] fix: Implement responsive Drawer for payment gateway settings on mobile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Payment gateway settings modal was using Dialog on all screen sizes Solution: Split into responsive Dialog (desktop) and Drawer (mobile) Changes: 1. Added Drawer and useMediaQuery imports 2. Added isDesktop hook: useMediaQuery("(min-width: 768px)") 3. Split modal into two conditional renders: - Desktop (≥768px): Dialog with horizontal footer layout - Mobile (<768px): Drawer with vertical footer layout Desktop Layout (Dialog): - Center modal overlay - Horizontal footer: Cancel | View in WC | Save - max-h-[80vh] for scrolling Mobile Layout (Drawer): - Bottom sheet (slides up from bottom) - Vertical footer (full width buttons): 1. Save Settings (primary) 2. View in WooCommerce (ghost) 3. Cancel (outline) - max-h-[90vh] for more screen space - Swipe down to dismiss Benefits: ✅ Native mobile experience with bottom sheet ✅ Easier to reach buttons on mobile (bottom of screen) ✅ Better one-handed use ✅ Swipe gesture to dismiss ✅ Desktop keeps familiar modal experience User Changes Applied: - AlertDialog z-index: z-50 → z-[999] (higher than other modals) - Dialog max-height: max-h-[100vh] → max-h-[80vh] (better desktop UX) Files Modified: - Payments.tsx: Responsive Dialog/Drawer implementation - alert-dialog.tsx: Increased z-index for proper layering --- admin-spa/src/App.tsx | 2 +- admin-spa/src/components/ui/alert-dialog.tsx | 4 +- admin-spa/src/routes/Settings/Payments.tsx | 72 +++++++++++++++++--- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/admin-spa/src/App.tsx b/admin-spa/src/App.tsx index 9131128..fc932e2 100644 --- a/admin-spa/src/App.tsx +++ b/admin-spa/src/App.tsx @@ -57,7 +57,7 @@ function useFullscreen() { .wnw-fullscreen .woonoow-fullscreen-root { position: fixed; inset: 0; - z-index: 9999; + z-index: 999; background: var(--background, #fff); height: 100dvh; /* ensure full viewport height on mobile/desktop */ overflow: hidden; /* prevent double scrollbars; inner
handles scrolling */ diff --git a/admin-spa/src/components/ui/alert-dialog.tsx b/admin-spa/src/components/ui/alert-dialog.tsx index fa2b442..a6a26c0 100644 --- a/admin-spa/src/components/ui/alert-dialog.tsx +++ b/admin-spa/src/components/ui/alert-dialog.tsx @@ -16,7 +16,7 @@ const AlertDialogOverlay = React.forwardRef< >(({ className, ...props }, ref) => ( (null); const [isModalOpen, setIsModalOpen] = useState(false); const [togglingGateway, setTogglingGateway] = useState(null); + const isDesktop = useMediaQuery("(min-width: 768px)"); // Fetch all payment gateways const { data: gateways = [], isLoading, refetch } = useQuery({ @@ -261,10 +264,10 @@ export default function PaymentsPage() { )} - {/* Gateway Settings Modal */} - {selectedGateway && ( + {/* Gateway Settings Modal - Responsive: Dialog on desktop, Drawer on mobile */} + {selectedGateway && isDesktop && ( - + {selectedGateway.title} Settings @@ -277,22 +280,20 @@ export default function PaymentsPage() { /> {/* Footer outside scrollable area */} -
+
-
)} + + {selectedGateway && !isDesktop && ( + + + + {selectedGateway.title} Settings + +
+ setIsModalOpen(false)} + hideFooter + /> +
+ {/* Footer outside scrollable area */} +
+ + + +
+ + + )} ); }