Skip to content

Build your personal knowledge base with Trilium Notes

feat(options): open in a modal by default

Elian Doran24b89d39a8d2
diff --git a/apps/client/src/components/root_command_executor.ts b/apps/client/src/components/root_command_executor.ts
index 24c372d349..7fb1f66d51 100644
--- a/apps/client/src/components/root_command_executor.ts
+++ b/apps/client/src/components/root_command_executor.ts
@@ -113,11 +113,11 @@ export default class RootCommandExecutor extends Component {
await this.showAndHoistSubtree("_hidden");
}
- async showOptionsCommand({ section }: CommandListenerData<"showOptions">) {
- await appContext.tabManager.openContextWithNote(section || "_options", {
- activate: true,
- hoistedNoteId: "_options"
- });
+ showOptionsCommand({ section }: CommandListenerData<"showOptions">) {
+ // Open settings in the quick-edit popup on the first page (Appearance) by default, instead
+ // of opening a new hoisted tab (which confused users by seemingly hiding the note tree).
+ // The in-page settings selector lets users switch between pages from within the popup.
+ void appContext.triggerCommand("openInPopup", { noteIdOrPath: section ?? "_optionsAppearance" });
}
async showSQLConsoleHistoryCommand() {
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index 4ee79f33ea..2d1bb905a8 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -399,7 +399,10 @@ export function useNoteContext() {
}, [ notePath ]);
useTriliumEvents([ "setNoteContext", "activeContextChanged", "noteSwitchedAndActivated", "noteSwitched" ], ({ noteContext }) => {
- if (noteContextContext) return;
+ // When bound to a specific context via the provider (the quick-edit popup), ignore events for
+ // other contexts, but still react when our own bound context navigates in place (e.g. switching
+ // settings pages from the in-popup selector) — otherwise the popup would stay on the first page.
+ if (noteContextContext && noteContext !== noteContextContext) return;
setNoteContext(noteContext);
setHoistedNoteId(noteContext.hoistedNoteId);
setNotePath(noteContext.notePath);
diff --git a/apps/client/src/widgets/type_widgets/ContentWidget.tsx b/apps/client/src/widgets/type_widgets/ContentWidget.tsx
index b524e0b26a..10d6f039ec 100644
--- a/apps/client/src/widgets/type_widgets/ContentWidget.tsx
+++ b/apps/client/src/widgets/type_widgets/ContentWidget.tsx
@@ -63,7 +63,7 @@ export default function ContentWidget({ note, ...restProps }: TypeWidgetProps) {
if (isOptions) {
return (
<div className="options-with-nav">
- <SettingsNavigation activeNoteId={note.noteId} />
+ <SettingsNavigation activeNoteId={note.noteId} noteContext={restProps.noteContext} />
<div className="note-detail-content-widget-content options">
{content}
</div>
diff --git a/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.tsx b/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.tsx
index 25c8292785..370a9f59d1 100644
--- a/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/SettingsNavigation.tsx
@@ -2,34 +2,45 @@ import "./SettingsNavigation.css";
import clsx from "clsx";
+import NoteContext from "../../../../components/note_context";
import { useChildNotes } from "../../../react/hooks";
interface SettingsNavigationProps {
/** Note ID of the settings page currently being displayed (e.g. `_optionsAppearance`). */
activeNoteId: string;
+ /** The context the selector lives in, used to switch pages in place (e.g. inside the quick-edit popup). */
+ noteContext: NoteContext | undefined;
}
/**
* In-content selector for the settings pages, rendered alongside the active options page.
*
- * It mirrors the list of pages otherwise reached through the (hoisted) note tree, reading them
- * straight from the `_options` subtree so titles, icons and ordering stay in sync. Navigation
- * reuses the global link handler (`goToLink`) through plain note-path anchors, so clicking an
- * entry switches the page within the current tab and keeps the tree/hoisting in step.
+ * It mirrors the list of pages otherwise reached through the note tree, reading them straight from
+ * the `_options` subtree so titles, icons and ordering stay in sync. Clicking an entry switches the
+ * page within the current context — including the quick-edit popup, which has no note tree — while
+ * keeping the popup open. Modified clicks (ctrl/middle/shift) fall through to the global link handler
+ * so the page can still be opened in a new tab or window.
*/
-export default function SettingsNavigation({ activeNoteId }: SettingsNavigationProps) {
+export default function SettingsNavigation({ activeNoteId, noteContext }: SettingsNavigationProps) {
const pages = useChildNotes("_options");
return (
<nav className="settings-navigation">
{pages.map((page) => {
const isActive = page.noteId === activeNoteId;
+ const notePath = `root/_hidden/_options/${page.noteId}`;
return (
<a
key={page.noteId}
- href={`#root/_hidden/_options/${page.noteId}`}
+ href={`#${notePath}`}
className={clsx("settings-navigation-item no-tooltip-preview", { active: isActive })}
aria-current={isActive ? "page" : undefined}
+ onClick={(e) => {
+ if (!noteContext || e.button !== 0 || e.ctrlKey || e.metaKey || e.shiftKey) return;
+ e.preventDefault();
+ e.stopPropagation();
+ void noteContext.setNote(notePath, { keepActiveDialog: true });
+ }}
>
<span className={page.getIcon()} />
<span className="settings-navigation-title">{page.title}</span>