Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(options/mobile): remove animation on first show
Elian Doran6f6cb35a1d9c
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.css b/apps/client/src/widgets/dialogs/OptionsDialog.cssindex d65eb1ed82..5e76e828fc 100644--- a/apps/client/src/widgets/dialogs/OptionsDialog.css+++ b/apps/client/src/widgets/dialogs/OptionsDialog.css@@ -95,21 +95,23 @@ body.mobile .modal.options-dialog.mobile-view-page .modal-header > .modal-title/* Sliding transition between the two views, mirroring the setup wizard's page animation: the pageslides in from the end side, the list back in from the start side. Becoming displayed restarts- the animation, so the incoming pane animates exactly when the view switches. The global- `motion-disabled` rule suppresses these when animations are turned off in the settings. */-body.mobile .modal.options-dialog.mobile-view-page .modal-body {+ the animation, so the incoming pane animates exactly when the view switches. The+ `animate-view-switch` class is only present once the user switched views within the open dialog,+ keeping the initial view from sliding when the dialog opens. The global `motion-disabled` rule+ suppresses these when animations are turned off in the settings. */+body.mobile .modal.options-dialog.animate-view-switch.mobile-view-page .modal-body {animation: options-slide-in-end 0.35s ease-in-out;}-body.mobile .modal.options-dialog.mobile-view-list .modal-sidebar {+body.mobile .modal.options-dialog.animate-view-switch.mobile-view-list .modal-sidebar {animation: options-slide-in-start 0.35s ease-in-out;}-body[dir=rtl].mobile .modal.options-dialog.mobile-view-page .modal-body {+body[dir=rtl].mobile .modal.options-dialog.animate-view-switch.mobile-view-page .modal-body {animation-name: options-slide-in-start;}-body[dir=rtl].mobile .modal.options-dialog.mobile-view-list .modal-sidebar {+body[dir=rtl].mobile .modal.options-dialog.animate-view-switch.mobile-view-list .modal-sidebar {animation-name: options-slide-in-end;}diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.tsx b/apps/client/src/widgets/dialogs/OptionsDialog.tsxindex 47be2c4919..14f154891e 100644--- a/apps/client/src/widgets/dialogs/OptionsDialog.tsx+++ b/apps/client/src/widgets/dialogs/OptionsDialog.tsx@@ -33,6 +33,9 @@ export default function OptionsDialog() {const [ lastSection, setLastSection ] = useState<string | null>(null);// Which half of the mobile master-detail flow is visible; has no effect on desktop.const [ mobileView, setMobileView ] = useState<"list" | "page">("list");+ // Whether the user switched views since the dialog was opened. Gates the slide animation so+ // that only actual list/page switches animate, not the initial view when the dialog opens.+ const [ viewSwitched, setViewSwitched ] = useState(false);const modalRef = useRef<HTMLDivElement>(null);const isMobile = utils.isMobile();@@ -45,6 +48,7 @@ export default function OptionsDialog() {setNoteContext(noteContext);// Requesting a specific section (e.g. "set up a password") skips the mobile master list.setMobileView(section ? "page" : "list");+ setViewSwitched(false);setShown(true);});@@ -54,7 +58,8 @@ export default function OptionsDialog() {useEffect(() => {modalRef.current?.classList.toggle("mobile-view-list", mobileView === "list");modalRef.current?.classList.toggle("mobile-view-page", mobileView === "page");- }, [ mobileView ]);+ modalRef.current?.classList.toggle("animate-view-switch", viewSwitched);+ }, [ mobileView, viewSwitched ]);// Keep navigation between settings pages (sidebar entries, "Related settings" links) inside the// dialog; links to regular notes open in the quick-edit popup instead.@@ -62,6 +67,7 @@ export default function OptionsDialog() {if (notePath.split("/").at(-1)?.startsWith("_options")) {void noteContext.setNote(notePath, { viewScope, keepActiveDialog: true });setMobileView("page");+ setViewSwitched(true);} else {void appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath });}@@ -72,7 +78,10 @@ export default function OptionsDialog() {<ModalmodalRef={modalRef}title={t("options.title")}- header={isMobile && mobileView === "page" ? <MobilePageHeader onBack={() => setMobileView("list")} /> : undefined}+ header={isMobile && mobileView === "page" ? <MobilePageHeader onBack={() => {+ setMobileView("list");+ setViewSwitched(true);+ }} /> : undefined}sidebar={<SettingsSidebar />}isFullPageOnMobilecustomTitleBarButtons={[{