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 && (
<>
+29 -5
View File
@@ -190,11 +190,20 @@
}
/* Mobile Edit Modal */
.mobile-edit-overlay {
align-items: flex-start;
padding-top: 0.75rem;
padding-bottom: 0.75rem;
}
.edit-modal {
max-width: 95vw;
max-height: 90vh;
overflow-y: auto;
max-height: none;
height: min(92dvh, 92vh);
padding: 0.75rem;
display: flex;
flex-direction: column;
overflow: hidden;
}
.edit-modal-header {
@@ -211,9 +220,24 @@
}
.mobile-edit-form.form-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
gap: 0.75rem 1rem;
display: flex;
flex-direction: column;
gap: 0.75rem;
flex: 1;
min-height: 0;
overflow: hidden;
}
.mobile-edit-form .readonly-fieldset {
display: block;
flex: 1;
min-height: 0;
overflow-y: auto;
overscroll-behavior: contain;
}
.mobile-edit-form .form-tab-panel.active {
display: block;
}
.mobile-edit-form.form-grid > label {