fix: stabilize dashboard modal and image click behavior (#267)
* feat: make medication names clickable in Dashboard dose schedule Add click handlers to med-name-stack divs in all three dose schedule sections (past, current/overdue, future) on DashboardPage, opening the MedDetail modal on click. Add early-return guards to all four modal openers in AppContext (openMedDetail, openImageLightbox, openScheduleLightbox, openUserFilter) to prevent duplicate pushState entries on double-click, which caused unexpected navigation to the Medications page. Closes #266 * fix: stabilize dashboard modal and image click handling * fix: close medication detail on first backdrop click
This commit is contained in:
@@ -74,6 +74,10 @@ export function MedicationsPage() {
|
||||
|
||||
// Mobile modal state (declared early because it's used in useEffect below)
|
||||
const [showEditModal, setShowEditModal] = useState(false);
|
||||
const showEditModalRef = useRef(false);
|
||||
useEffect(() => {
|
||||
showEditModalRef.current = showEditModal;
|
||||
}, [showEditModal]);
|
||||
const processedEditMedIdRef = useRef<string | null>(null);
|
||||
const hasDesktopFormHistoryState = useRef(false);
|
||||
|
||||
@@ -199,6 +203,8 @@ export function MedicationsPage() {
|
||||
|
||||
// Open mobile edit modal
|
||||
function openEditModal() {
|
||||
if (showEditModalRef.current) return;
|
||||
showEditModalRef.current = true;
|
||||
setShowEditModal(true);
|
||||
window.history.pushState({ modal: "edit" }, "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user