Skip to content

Build your personal knowledge base with Trilium Notes

fix(modal): let a scrollable modal with a form actually scroll

Elian Doranf3ba8c1d9e93
diff --git a/apps/client/src/widgets/react/Modal.css b/apps/client/src/widgets/react/Modal.css
new file mode 100644
index 0000000000..7232bce291
--- /dev/null
+++ b/apps/client/src/widgets/react/Modal.css
@@ -0,0 +1,18 @@
+/**
+ * Bootstrap scrolls a modal by capping `.modal-content`'s height and letting the
+ * `.modal-body` flex item shrink inside it. A modal given `onSubmit` wraps the
+ * body and footer in a <form>, which lands between the two: a block-level form
+ * neither shrinks (its automatic minimum size is its content) nor passes the flex
+ * sizing on, so the body keeps its full height, `overflow-y: auto` finds nothing
+ * to scroll, and `.modal-content`'s own `overflow: hidden` simply clips the
+ * overflowing content — footer included.
+ *
+ * Making the form a flex column that may shrink puts it back in the chain.
+ * `overflow` is deliberately left visible so footer dropdowns still escape.
+ */
+.modal-dialog-scrollable > .modal-content > form,
+.modal-dialog-scrollable > .modal-content > .modal-main > form {
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+}
diff --git a/apps/client/src/widgets/react/Modal.tsx b/apps/client/src/widgets/react/Modal.tsx
index 2a995ba651..1d0fa140fa 100644
--- a/apps/client/src/widgets/react/Modal.tsx
+++ b/apps/client/src/widgets/react/Modal.tsx
@@ -1,3 +1,5 @@
+import "./Modal.css";
+
import { Modal as BootstrapModal } from "bootstrap";
import clsx from "clsx";
import { ComponentChildren, CSSProperties, RefObject } from "preact";