Skip to content

Build your personal knowledge base with Trilium Notes

fix(options): wrong layout on mobile tablet

Elian Dorana38a22bd838f
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.css b/apps/client/src/widgets/dialogs/OptionsDialog.css
index ac2093c3eb..90a29c692d 100644
--- a/apps/client/src/widgets/dialogs/OptionsDialog.css
+++ b/apps/client/src/widgets/dialogs/OptionsDialog.css
@@ -44,12 +44,38 @@ body.desktop .modal.options-dialog .note-detail-content-widget-content.options {
padding-top: var(--options-first-item-top-margin);
}
-/* On mobile the dialog becomes a master-detail flow instead of the sidebar layout: the page
- selector is rendered as a pane inside the modal body (the Modal sidebar is unused), so the list
- and the page can slide over each other when switching between them. */
-body.mobile .modal.options-dialog .modal-dialog .modal-content .modal-body {
- position: relative;
+/* The dialog fills the full mobile page (isFullPageOnMobile), so the body stretches instead of
+ using the fixed desktop height. Applies to both the master-detail and the tablet layout. */
+body.mobile .modal.options-dialog .modal-body {
+ height: auto;
+ flex: 1 1 auto;
+}
+
+/* On wider mobile viewports (tablets) the dialog keeps the desktop-style sidebar layout; undo the
+ generic bottom-strip arrangement that style.css applies to sidebar modals on mobile. The sidebar
+ only exists outside the master-detail flow, so no extra scoping is needed. */
+body.mobile .modal.options-dialog .modal-content-with-sidebar {
+ flex-direction: row !important;
+}
+
+body.mobile .modal.options-dialog .modal-content-with-sidebar > .modal-sidebar {
+ order: 0;
height: auto;
+ border-right: 1px solid var(--main-border-color);
+ border-bottom: none;
+}
+
+/* On tablets, don't take up the full page height like the master-detail flow does. */
+body.mobile .modal.options-dialog:not(.mobile-master-detail) .modal-dialog {
+ height: 90vh;
+}
+
+/* On narrow mobile viewports the dialog becomes a master-detail flow instead of the sidebar
+ layout (the `mobile-master-detail` class tracks this): the page selector is rendered as a pane
+ inside the modal body (the Modal sidebar is unused), so the list and the page can slide over
+ each other when switching between them. */
+body.mobile .modal.options-dialog.mobile-master-detail .modal-content .modal-body {
+ position: relative;
padding: 0;
/* The panes scroll themselves; this also keeps the sliding panes contained. */
overflow: hidden;
@@ -61,28 +87,28 @@ body.mobile .modal.options-dialog .options-mobile-nav {
padding: 8px 25px;
}
-body.mobile .modal.options-dialog .note-detail {
+body.mobile .modal.options-dialog.mobile-master-detail .note-detail {
height: 100%;
overflow: auto;
}
/* At rest only the active pane is displayed; during a transition both stay visible so the
outgoing pane can slide away as the incoming one slides in. */
-body.mobile .modal.options-dialog.mobile-view-list:not(.mobile-transition-to-list) .note-detail {
+body.mobile .modal.options-dialog.mobile-master-detail.mobile-view-list:not(.mobile-transition-to-list) .note-detail {
display: none;
}
-body.mobile .modal.options-dialog.mobile-view-page:not(.mobile-transition-to-page) .options-mobile-nav {
+body.mobile .modal.options-dialog.mobile-master-detail.mobile-view-page:not(.mobile-transition-to-page) .options-mobile-nav {
display: none;
}
-/* The back button + page title in the custom header replace the static "Options" title. */
body.mobile .modal.options-dialog .modal-header {
border-bottom: 1px solid var(--main-border-color);
+}
- > .modal-title {
- display: none;
- }
+/* The back button + page title in the custom header replace the static "Options" title. */
+body.mobile .modal.options-dialog.mobile-master-detail .modal-header > .modal-title {
+ display: none;
}
/* Directional slide mirroring the setup wizard's page animation: opening a page, the list slides
@@ -91,8 +117,8 @@ body.mobile .modal.options-dialog .modal-header {
off-screen position until the transition classes are removed after animationend. The global
`motion-disabled` rule suppresses the animations entirely; the dialog then switches views
directly without entering a transition. */
-body.mobile .modal.options-dialog.mobile-transition-to-page,
-body.mobile .modal.options-dialog.mobile-transition-to-list {
+body.mobile .modal.options-dialog.mobile-master-detail.mobile-transition-to-page,
+body.mobile .modal.options-dialog.mobile-master-detail.mobile-transition-to-list {
.options-mobile-nav,
.note-detail {
position: absolute;
@@ -105,7 +131,7 @@ body.mobile .modal.options-dialog.mobile-transition-to-list {
}
}
-body.mobile .modal.options-dialog.mobile-transition-to-page {
+body.mobile .modal.options-dialog.mobile-master-detail.mobile-transition-to-page {
.note-detail {
animation: options-slide-in-end 0.35s ease-in-out forwards;
}
@@ -115,7 +141,7 @@ body.mobile .modal.options-dialog.mobile-transition-to-page {
}
}
-body.mobile .modal.options-dialog.mobile-transition-to-list {
+body.mobile .modal.options-dialog.mobile-master-detail.mobile-transition-to-list {
.note-detail {
animation: options-slide-out-end 0.35s ease-in-out forwards;
}
@@ -125,7 +151,7 @@ body.mobile .modal.options-dialog.mobile-transition-to-list {
}
}
-body[dir=rtl].mobile .modal.options-dialog.mobile-transition-to-page {
+body[dir=rtl].mobile .modal.options-dialog.mobile-master-detail.mobile-transition-to-page {
.note-detail {
animation-name: options-slide-in-start;
}
@@ -135,7 +161,7 @@ body[dir=rtl].mobile .modal.options-dialog.mobile-transition-to-page {
}
}
-body[dir=rtl].mobile .modal.options-dialog.mobile-transition-to-list {
+body[dir=rtl].mobile .modal.options-dialog.mobile-master-detail.mobile-transition-to-list {
.note-detail {
animation-name: options-slide-out-start;
}
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.tsx b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
index f0eacbd661..4dca179be6 100644
--- a/apps/client/src/widgets/dialogs/OptionsDialog.tsx
+++ b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
@@ -9,7 +9,7 @@ import utils from "../../services/utils";
import NoteDetail from "../NoteDetail";
import ActionButton from "../react/ActionButton";
import FormList, { FormListItem } from "../react/FormList";
-import { useChildNotes, useContainedLinkNavigation, useNoteContext, useTriliumEvent } from "../react/hooks";
+import { useChildNotes, useContainedLinkNavigation, useNoteContext, useTriliumEvent, useWindowSize } from "../react/hooks";
import Modal from "../react/Modal";
import { NoteContextContext, ParentComponent } from "../react/react_utils";
import SettingsNavigation from "../type_widgets/options/components/SettingsNavigation";
@@ -17,6 +17,10 @@ import SettingsNavigation from "../type_widgets/options/components/SettingsNavig
/** The settings page shown when no specific section was requested and none was viewed yet this session. */
const DEFAULT_SECTION = "_optionsAppearance";
+/** Mobile viewports at least this wide (tablets) keep the desktop-style side-by-side sidebar
+ * layout; narrower ones get the master-detail flow. */
+const TABLET_MIN_WIDTH = 768;
+
/**
* The settings dialog, opened via the `showOptions` command. Settings open in a dialog rather than
* a hoisted tab (which confused users by seemingly hiding the note tree): the full-height sidebar
@@ -40,6 +44,9 @@ export default function OptionsDialog() {
const [ mobileTransition, setMobileTransition ] = useState<"to-list" | "to-page" | null>(null);
const modalRef = useRef<HTMLDivElement>(null);
const isMobile = utils.isMobile();
+ const { windowWidth } = useWindowSize();
+ // Only narrow mobile viewports get the master-detail flow; tablets keep the sidebar layout.
+ const isMasterDetail = isMobile && windowWidth < TABLET_MIN_WIDTH;
// Switches between the mobile master/detail views with a slide. The initial view on open is
// set directly (without animating) by the showOptions handler instead.
@@ -47,11 +54,11 @@ export default function OptionsDialog() {
if (view === mobileView) return;
setMobileView(view);
// With animations globally disabled there is no animationend to clear the transition,
- // so switch directly.
- if (!document.body.classList.contains("motion-disabled")) {
+ // so switch directly. Outside the master-detail flow there is nothing to animate.
+ if (isMasterDetail && !document.body.classList.contains("motion-disabled")) {
setMobileTransition(view === "page" ? "to-page" : "to-list");
}
- }, [ mobileView ]);
+ }, [ mobileView, isMasterDetail ]);
useTriliumEvent("showOptions", async ({ section }) => {
const noteContext = new NoteContext("_options-dialog");
@@ -70,11 +77,12 @@ export default function OptionsDialog() {
// className prop must stay static — rewriting it from a render would wipe them and visually
// dismiss the dialog. Toggle the mobile view classes directly on the element instead.
useEffect(() => {
+ modalRef.current?.classList.toggle("mobile-master-detail", isMasterDetail);
modalRef.current?.classList.toggle("mobile-view-list", mobileView === "list");
modalRef.current?.classList.toggle("mobile-view-page", mobileView === "page");
modalRef.current?.classList.toggle("mobile-transition-to-list", mobileTransition === "to-list");
modalRef.current?.classList.toggle("mobile-transition-to-page", mobileTransition === "to-page");
- }, [ mobileView, mobileTransition ]);
+ }, [ isMasterDetail, mobileView, mobileTransition ]);
// End the view transition once the slide finishes (animationend bubbles up from the panes).
useEffect(() => {
@@ -105,8 +113,8 @@ export default function OptionsDialog() {
<Modal
modalRef={modalRef}
title={t("options.title")}
- header={isMobile && (mobileView === "page" ? <MobilePageHeader onBack={() => switchMobileView("list")} /> : <MobilePageHeader />)}
- sidebar={isMobile ? undefined : <SettingsSidebar />}
+ header={isMasterDetail && (mobileView === "page" ? <MobilePageHeader onBack={() => switchMobileView("list")} /> : <MobilePageHeader />)}
+ sidebar={isMasterDetail ? undefined : <SettingsSidebar />}
isFullPageOnMobile
customTitleBarButtons={!isMobile ? [{
iconClassName: "bx-expand-alt",
@@ -129,7 +137,7 @@ export default function OptionsDialog() {
setShown(false);
}}
>
- {isMobile && (
+ {isMasterDetail && (
<div className="options-mobile-nav">
<MobileSettingsList onSelect={(noteId) => {
void noteContext.setNote(noteId, { keepActiveDialog: true });