fix: improve mobile edit modal scrolling behavior (#247)

This commit is contained in:
Daniel Volz
2026-02-21 15:24:57 +01:00
committed by GitHub
parent 612aa007aa
commit fd3b770a81
2 changed files with 42 additions and 8 deletions
+13 -3
View File
@@ -122,13 +122,23 @@ export function MobileEditModal({
return () => document.removeEventListener("keydown", handleKeyDown);
}, [show, onClose]);
// Lock background scroll while modal is open.
useEffect(() => {
if (!show) return;
const previousOverflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
return () => {
document.body.style.overflow = previousOverflow;
};
}, [show]);
if (!show) return null;
const currentMed = editingId ? meds.find((m) => m.id === editingId) : null;
return (
<div
className="modal-overlay"
className="modal-overlay mobile-edit-overlay"
onClick={onClose}
onKeyDown={(e) => {
if (e.key === "Escape") onClose();
@@ -446,14 +456,14 @@ export function MobileEditModal({
<h4 className="form-category-title">{t("form.sections.prescription")}</h4>
<label className="full">
{t("prescription.enabled")}
<label className="toggle-switch small">
<span className="toggle-switch small">
<input
type="checkbox"
checked={form.prescriptionEnabled}
onChange={(e) => onHandleValueChange("prescriptionEnabled", e.target.checked)}
/>
<span className="toggle-slider"></span>
</label>
</span>
</label>
{form.prescriptionEnabled && (
<>