Skip to content

Build your personal knowledge base with Trilium Notes

client/options: make a layout overhaul for the mobile UI

Adorian Doran240369eda90d
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.css b/apps/client/src/widgets/dialogs/OptionsDialog.css
index 5bed021526..0966ffeda0 100644
--- a/apps/client/src/widgets/dialogs/OptionsDialog.css
+++ b/apps/client/src/widgets/dialogs/OptionsDialog.css
@@ -80,8 +80,30 @@ body.mobile .modal.options-dialog:not(.mobile-master-detail) > .modal-dialog {
/* The master-detail flow itself is the shared one (master_detail.css); what is particular here is the
page selector's own padding, and the settings page filling the pane it is wrapped in. */
body.mobile .modal.options-dialog.mobile-master-detail {
+ /* What a card keeps from the edge of the screen: 16px, which is both Material's body margin for
+ a compact window and the inset iOS gives a grouped list, and which with the card's own 16px
+ starts the text 32px in, where a phone is read. Widened where a sensor housing eats into
+ the screen, which is a side of it rather than the start of a sentence: hence left and right,
+ not start and end. */
+ --options-inset-left: max(16px, env(safe-area-inset-left));
+ --options-inset-right: max(16px, env(safe-area-inset-right));
+
+ /* The room a scrolling pane keeps for its bar, held on both edges rather than the trailing one
+ alone: on one edge the cards sit off centre whenever the bar is absent, and a bar that comes
+ and goes as the page settles moves them about and reflows their text. The pane already holds
+ that much of the margin, so whatever stands inside it pads only what is left of it. */
+ --options-gutter: var(--scrollbar-thickness, 10px);
+ --options-pane-inset-left: max(0px, calc(var(--options-inset-left) - var(--options-gutter)));
+ --options-pane-inset-right: max(0px, calc(var(--options-inset-right) - var(--options-gutter)));
+
+ .tn-master-pane {
+ scrollbar-gutter: stable both-edges;
+ }
+
.options-mobile-nav {
- padding: 8px 25px;
+ padding-block: 8px;
+ padding-left: var(--options-pane-inset-left);
+ padding-right: var(--options-pane-inset-right);
/* The list is the pane's own content here, not a menu standing over something else. */
.dropdown-menu.static {
@@ -89,6 +111,32 @@ body.mobile .modal.options-dialog.mobile-master-detail {
}
}
+ /* Held to the same margin whatever the page: its own is a desktop measure, and in the old
+ layout it has none of its own at all. */
+ .note-detail-content-widget-content.options {
+ padding-left: var(--options-pane-inset-left);
+ padding-right: var(--options-pane-inset-right);
+ }
+
+ /* The bar above the cards keeps their margin, so the way back starts on the rail the cards
+ start on and the close button ends on the one they end on. `!important` answers the global
+ rule, which is in `rem` besides and would drift from a fixed inset as the text is resized. */
+ .modal-header {
+ padding-left: var(--options-inset-left) !important;
+ padding-right: var(--options-inset-right) !important;
+ }
+
+ /* Reaches both edges of the pane, its border with it, and takes the inset back as padding so
+ what it holds still lines up with the cards. The page's own gap above it is taken back too:
+ one bar standing at the top of the page wants one gap over its contents, not two. */
+ .options-page-header {
+ margin-top: calc(var(--default-padding, 15px) * -1);
+ margin-left: calc(var(--options-pane-inset-left) * -1);
+ margin-right: calc(var(--options-pane-inset-right) * -1);
+ padding-left: var(--options-pane-inset-left);
+ padding-right: var(--options-pane-inset-right);
+ }
+
/* Left to scroll away with the list beneath it, as a phone's search fields do. */
.settings-search {
margin-bottom: 12px;
@@ -102,6 +150,7 @@ body.mobile .modal.options-dialog.mobile-master-detail {
.note-detail {
height: 100%;
overflow: auto;
+ scrollbar-gutter: stable both-edges;
}
}
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.tsx b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
index 7dbf0bba80..8c40552d1f 100644
--- a/apps/client/src/widgets/dialogs/OptionsDialog.tsx
+++ b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
@@ -10,10 +10,12 @@ import { t } from "../../services/i18n";
import utils, { isElectron, isStandalone } from "../../services/utils";
import NoteDetail from "../NoteDetail";
import FormList, { FormListItem } from "../react/FormList";
+import HelpButton from "../react/HelpButton";
import { useChildNotes, useContainedLinkNavigation, useNoteContext, useTriliumEvent } from "../react/hooks";
import { DetailPane, MasterDetailHeader, MasterPane, useMobileMasterDetail } from "../react/master_detail";
import Modal from "../react/Modal";
import { NoteContextContext, ParentComponent } from "../react/react_utils";
+import { PageHelpSlot } from "../type_widgets/options/components/OptionsPageHeader";
import SettingsNavigation from "../type_widgets/options/components/SettingsNavigation";
import SettingsSearch from "../type_widgets/options/components/SettingsSearch";
import OptionsSearchPage, { hasSearchTerms } from "../type_widgets/options/search_page";
@@ -41,6 +43,8 @@ export default function OptionsDialog() {
// typed, and picking a page closes it again without emptying the field.
const [ searchQuery, setSearchQuery ] = useState("");
const [ searching, setSearching ] = useState(false);
+ // Where the page on show keeps its help mark while the master-detail header carries its name.
+ const [ pageHelpUrl, setPageHelpUrl ] = useState<string>();
const modalRef = useRef<HTMLDivElement>(null);
const isMobile = utils.isMobile();
const { isMasterDetail, mobileView, switchMobileView, resetMobileView } = useMobileMasterDetail(modalRef);
@@ -87,6 +91,7 @@ export default function OptionsDialog() {
pageTitle={<ActivePageTitle />}
listTitle={t("options.title")}
listIcon="bx bx-cog"
+ pageActions={pageHelpUrl && <HelpButton helpPage={pageHelpUrl} />}
/>
)}
sidebar={isMasterDetail ? undefined : (
@@ -148,7 +153,13 @@ export default function OptionsDialog() {
there is a flow for it to be half of: the sidebar layout expects it as the body's own
child. */}
{isMasterDetail
- ? <DetailPane><NoteDetail /></DetailPane>
+ ? (
+ // Offered only here: elsewhere the page's banner keeps its own name, and so
+ // has somewhere for the mark to sit.
+ <PageHelpSlot.Provider value={setPageHelpUrl}>
+ <DetailPane><NoteDetail /></DetailPane>
+ </PageHelpSlot.Provider>
+ )
: (searching ? <OptionsSearchPage query={searchQuery} /> : <NoteDetail />)}
</Modal>
</NoteContextContext.Provider>
diff --git a/apps/client/src/widgets/dialogs/image_compression/image_compression_dialog.spec.tsx b/apps/client/src/widgets/dialogs/image_compression/image_compression_dialog.spec.tsx
index f2f09746ab..a30afa3624 100644
--- a/apps/client/src/widgets/dialogs/image_compression/image_compression_dialog.spec.tsx
+++ b/apps/client/src/widgets/dialogs/image_compression/image_compression_dialog.spec.tsx
@@ -143,7 +143,7 @@ function rows(within: ParentNode = document.body) {
const titles = () => titlesOf(document.body);
const titlesOf = (within: ParentNode) =>
- rows(within).map((row) => row.querySelector(".image-compression-section-title")?.textContent);
+ rows(within).map((row) => row.querySelector(".tn-card-option-title")?.textContent);
const cards = () => Array.from(document.body.querySelectorAll<HTMLElement>(".modal-stub .tn-card"));
const numberField = () => document.body.querySelector<HTMLInputElement>(".image-compression-section-number");
@@ -151,7 +151,7 @@ const slider = () => document.body.querySelector<HTMLInputElement>(".slider");
const qualityRows = () => rows().filter((row) => !!row.querySelector(".slider"));
const qualityReading = () => document.body.querySelector(".image-compression-section-value")?.textContent ?? "";
const toggles = () => Array.from(document.body.querySelectorAll<HTMLInputElement>(".switch-toggle"));
-const hasHelp = (row: HTMLElement) => !!row.querySelector(".image-compression-section-title .contextual-help");
+const hasHelp = (row: HTMLElement) => !!row.querySelector(".tn-card-option-title .contextual-help");
/** The buttons of one format's choice, the groups being in the order the card lists them. */
const choiceButtons = (group: number) =>
@@ -333,7 +333,7 @@ describe("showImageCompressionDialog", () => {
// A slider says which way it is going but never where it is, so the row reads
// title, value, control — the reading placed before the control it reads.
expect(Array.from(qualityRows()[0].children).map((child) => child.classList[0])).toEqual([
- "image-compression-section-title",
+ "tn-card-option-title",
"image-compression-section-value",
"slider"
]);
diff --git a/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.css b/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.css
index 7b16272fe4..a2ff5a3186 100644
--- a/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.css
+++ b/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.css
@@ -1,35 +1,20 @@
-/* One row per setting: title on the leading edge, its control on the trailing one, so a stack of
- them reads as a column of labels and a column of controls whichever card they were dropped into. */
+/* Built on the card's own option row (`.tn-card-option`), so the narrow layout, the stacking and
+ the combo styling reach these without being written again. What is left here is what a
+ compression row needs beyond an ordinary one. */
.image-compression-section {
- display: flex;
- align-items: center;
gap: 10px;
- /* Takes the slack, so every control sits at the trailing edge whatever the title — and never
+ /* Takes the slack, so every control sits at the trailing edge whatever the title, and never
gives any back: an unwrapped title is what widens the dialog holding it. */
- .image-compression-section-title {
+ .tn-card-option-title {
flex: 1 0 auto;
white-space: nowrap;
}
- /* A described row: the title and its sentence stack, and the pair takes the slack the title
- alone would have taken. Unlike the title it may shrink, since a sentence wraps where a label
- does not — and it needs to, or a long description would push the control off the row. */
- .image-compression-section-label {
- display: flex;
- flex: 1 1 auto;
- flex-direction: column;
- gap: 2px;
- min-width: 0;
-
- .image-compression-section-title {
- white-space: normal;
- }
- }
-
- .image-compression-section-description {
- color: var(--muted-text-color);
- font-size: 0.85em;
+ /* Described, the sentence wraps where a label does not, and the title with it: otherwise a long
+ description pushes the control off the row. */
+ .tn-card-option-label .tn-card-option-title {
+ white-space: normal;
}
/* Where the slider currently is, which the slider itself cannot say. Fixed-width digits so the
@@ -58,32 +43,35 @@
width: 140px;
}
- /* The switch brings its own label slot, unused here — the row's own title names the setting. */
- .switch-widget {
- flex: 0 0 auto;
- }
-
/* Never wraps: the choices are read across, and a button folding onto a second line would
break the row into two heights. A long translation widens the dialog instead. */
.image-compression-section-choice {
flex: 0 0 auto;
white-space: nowrap;
- /* Smaller than the label it answers: three of these across a row read as a control, where at
- full size they compete with the title for it. */
+ /* Smaller than the label it answers: three of these across a row read as a control,
+ where at full size they compete with the title for it. */
font-size: 0.85em;
}
}
/* Indented by the card itself; quieting the title is what marks it as qualifying the row above
rather than standing beside it. */
-.image-compression-section-nested .image-compression-section-title {
+.image-compression-section-nested .tn-card-option-title {
color: var(--muted-text-color);
}
+/* No width left to widen into, so the title wraps rather than running past the card. The bound it
+ otherwise sets on the dialog is a desktop concern only. */
+@container (max-width: 500px) {
+ .image-compression-section .tn-card-option-title {
+ white-space: normal;
+ }
+}
+
/* Prose rather than a row of controls, so none of the row layout applies to it. A fit-content
dialog takes its width from the longest unbroken line in it, and this sentence would otherwise
- be that line; containment says the part that is true — this row's width does not depend on what
- is written in it — so the dialog is sized by the rows that should size it. */
+ be that line; containment says the part that is true: this row's width does not depend on what
+ is written in it, so the dialog is sized by the rows that should size it. */
.image-compression-notice {
contain: inline-size;
color: var(--muted-text-color);
diff --git a/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.tsx b/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.tsx
index 4647d76e4b..27730e0d79 100644
--- a/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.tsx
+++ b/apps/client/src/widgets/dialogs/image_compression/image_compression_sections.tsx
@@ -69,7 +69,7 @@ export function ResizeImageSection(props: ImageCompressionSectionProps) {
return (
<CardSection
- className="image-compression-section"
+ className="tn-card-option image-compression-section"
subSectionsVisible={options.resize}
subSections={[ <MaxImageDimensionsSection key="max-dimensions" {...props} /> ]}
>
@@ -90,7 +90,7 @@ export function ResizeImageSection(props: ImageCompressionSectionProps) {
/** The bound an image is scaled down to fit. */
export function MaxImageDimensionsSection({ options, onChange, disabled, descriptions }: ImageCompressionSectionProps) {
return (
- <CardSection className="image-compression-section image-compression-section-nested">
+ <CardSection className="tn-card-option image-compression-section image-compression-section-nested">
<SectionLabel
title={t("space_usage.compress_max_dimensions")}
description={descriptions?.maxWidthHeight}
@@ -120,7 +120,7 @@ export function JpegHandlingSection(props: ImageCompressionSectionProps) {
return (
<CardSection
- className="image-compression-section"
+ className="tn-card-option image-compression-section"
subSectionsVisible={options.jpegHandling === "compress"}
subSections={[ <JpegQualitySection key="quality" {...props} /> ]}
>
@@ -149,7 +149,7 @@ export function PngHandlingSection(props: ImageCompressionSectionProps) {
return (
<CardSection
- className="image-compression-section"
+ className="tn-card-option image-compression-section"
subSectionsVisible={options.pngHandling === "jpeg"}
subSections={[ <ConversionQualitySection key="conversion-quality" {...props} /> ]}
>
@@ -194,7 +194,7 @@ export function ConversionQualitySection({ options, onChange, disabled, descript
/** Whether the run reaches past the note it was invoked on, into its whole subtree. */
export function ProcessChildNotesSection({ options, onChange, disabled, descriptions }: ImageCompressionSectionProps) {
return (
- <CardSection className="image-compression-section">
+ <CardSection className="tn-card-option image-compression-section">
<SectionLabel
title={t("space_usage.compress_process_child_notes")}
help={t("space_usage.compress_process_child_notes_help")}
@@ -232,7 +232,7 @@ export function UnsupportedFormatNotice() {
*/
function SectionLabel({ title, help, description }: { title: string; help?: string; description?: string }) {
const label = (
- <span className="image-compression-section-title">
+ <span className="tn-card-option-title">
{title}
{help && <ContextualHelp helpMessage={help} />}
</span>
@@ -243,9 +243,9 @@ function SectionLabel({ title, help, description }: { title: string; help?: stri
}
return (
- <span className="image-compression-section-label">
+ <span className="tn-card-option-label">
{label}
- <small className="image-compression-section-description">{description}</small>
+ <small className="tn-card-option-description">{description}</small>
</span>
);
}
@@ -291,7 +291,7 @@ function QualitySlider({ value, onChange, disabled, description }: {
description?: string;
}) {
return (
- <CardSection className={clsx("image-compression-section", "image-compression-section-nested")}>
+ <CardSection className={clsx("tn-card-option image-compression-section", "image-compression-section-nested")}>
<SectionLabel title={t("space_usage.compress_quality")} description={description} />
<span className="image-compression-section-value">
{t("space_usage.compress_quality_value", { quality: value })}
diff --git a/apps/client/src/widgets/react/Card.css b/apps/client/src/widgets/react/Card.css
index b4f5aa0e5f..446c846554 100644
--- a/apps/client/src/widgets/react/Card.css
+++ b/apps/client/src/widgets/react/Card.css
@@ -4,6 +4,15 @@
--card-padding-inline: 16px;
--card-section-gap: 3px;
--card-nested-section-indent: 30px;
+ /* Worn as a mask rather than drawn, so whatever carries it sets the colour. */
+ --card-chevron: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m5 2 6 6-6 6'/></svg>");
+}
+
+/* Gives the options below a width to measure, so they stack by the room they have and not by the
+ device: the same card is read at 900px on a desktop page, 450px in the dialog on a tablet and
+ 300px in the phone's detail pane. */
+.tn-card {
+ container-type: inline-size;
}
.tn-card-frame,
@@ -77,6 +86,22 @@
opacity: .7;
}
+ /* A fact rather than a control: unlike the buttons a row is built around, a value gives way
+ when the line runs short, and breaks wherever it must rather than widening the card. */
+ .tn-card-option-value {
+ flex-shrink: 1;
+ min-width: 0;
+ text-align: end;
+ overflow-wrap: anywhere;
+ }
+
+ /* Small buttons acting on the row, held as one thing so that a row wearing two of them counts
+ for as much as a row wearing one. */
+ .tn-card-option-actions {
+ display: flex;
+ gap: 4px;
+ }
+
.btn {
white-space: nowrap;
}
@@ -95,11 +120,20 @@
}
}
+/* The mark of a row that leads somewhere, worn alike by a link, a font row and a combo box. */
+.tn-card-chevron,
.tn-card-section-chevron {
flex-shrink: 0;
+ width: .9em;
+ height: .9em;
+ background-color: var(--muted-text-color);
+ -webkit-mask: var(--card-chevron) center / contain no-repeat;
+ mask: var(--card-chevron) center / contain no-repeat;
+}
+
+/* A link's own mark is pushed to the trailing edge; one placed by a row is already there. */
+.tn-card-section-chevron {
margin-inline-start: auto;
- color: var(--muted-text-color);
- font-size: 1.3em;
}
/* Bootstrap sizes a form control to whatever holds it, so left alone a select or a figure takes the
@@ -133,13 +167,176 @@
}
}
-/* On a phone, a control too wide to sit beside the text takes the line below it. */
-body.mobile .tn-card-option:has(> .btn, > .slider) {
- flex-direction: column;
- align-items: stretch;
+/* On a narrow card a text box, a combo or any other wide control has no room left beside its label,
+ so it takes the line below it instead. Small controls stay beside the label: they leave it room,
+ and moving a switch down would cost a whole row and break the line the labels are read down. A
+ bare figure is small enough to stay; one carrying a unit beside it is not. A chevron is no
+ control at all but the mark of a row that leads somewhere, and keeps its place at every width. */
+@container (max-width: 500px) {
+ /* On a narrow card the name reads as a field label, set apart by weight rather than by size.
+ Every row gets it, or a card would mix two kinds of label between its rows. */
+ .tn-card-option-title {
+ font-weight: 600;
+ }
- > .slider {
- width: 100%;
+ /* Set here rather than on the card, which a query cannot reach from inside itself. Half the
+ nesting step, a narrow card having less width to spend on showing how deep a section sits;
+ and taller rows, since here a row is reached by finger rather than by pointer. */
+ .tn-card-body {
+ --card-nested-section-indent: 15px;
+ --card-padding-block: 12px;
+ }
+
+ .tn-card-option:not(:has(> :is(
+ .switch-widget, .icon-action, .tn-card-option-actions, select, .dropdown,
+ .tn-card-section-chevron, input[type="number"]
+ ))) {
+ flex-direction: column;
+ align-items: stretch;
+ /* Down the page the label already leads its control, so they need less room between. */
+ gap: 4px;
+
+ > * {
+ width: 100%;
+ }
+
+ /* Standing under its label rather than beside it, a value is read from the edge the label
+ starts at, not the one it was pushed against. */
+ > .tn-card-option-value {
+ text-align: start;
+ }
+ }
+
+ /* Beside a control, a sentence is left only a gutter to wrap in, and what explains a setting
+ runs long. Given a row of its own it reads across the card. Not every row, though: a stacked
+ one's label has the full width already, and a list of things (a token, a backup, a provider)
+ carries a short line under each name that reads better where it is, with the buttons that act
+ on it beside the pair. */
+ .tn-card-option:has(> :is(
+ .switch-widget, .tn-card-section-chevron, input[type="number"]
+ )):has(.tn-card-option-description) {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ grid-template-areas:
+ "title control"
+ "description description";
+ align-items: center;
+ column-gap: 8px;
+ /* The sentence stands off the row above by as much as the row stands off its edge. */
+ row-gap: var(--card-padding-block);
+
+ /* The label stops being a box of its own, so the lines it holds become items of the grid,
+ and the control falls into the one cell left on the first row. */
+ > .tn-card-option-label {
+ display: contents;
+ }
+
+ .tn-card-option-title {
+ grid-area: title;
+ }
+
+ .tn-card-option-description {
+ grid-area: description;
+ }
+ }
+
+ /* A combo is never typed into: it is tapped, and the picker takes the screen from there. So it
+ keeps its place beside the label and gives up its box, reading as the value plus a mark that
+ the row leads somewhere, which is the row the card's own links already make. The value gives
+ way before the label does, ending in an ellipsis where the two cannot both be shown. */
+ .tn-card .tn-card-option > :is(select, .dropdown),
+ .tn-card .tn-card-option > .dropdown > .btn {
+ flex-shrink: 1;
+ min-width: 0;
+ }
+
+ .tn-card .tn-card-option > select,
+ .tn-card .tn-card-option > .dropdown > .btn {
+ max-width: none;
+ padding-inline: 0;
+ background: none;
+ color: var(--muted-text-color);
+ overflow: hidden;
+ text-align: end;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ /* Each state the theme gives a combo box would put the frame and the arrow back, so all of them
+ are answered here. */
+ .tn-card .tn-card-option > select:is(:hover, :focus, :focus-visible, :active),
+ .tn-card .tn-card-option > .dropdown > .btn:is(:hover, :focus, :focus-visible, :active) {
+ box-shadow: none;
+ background: none;
+ color: var(--muted-text-color);
+ }
+
+ /* No ring around a box that is gone. On a phone only: a desktop window this narrow is still
+ moved through by keyboard, and the outline is the one thing showing where the focus sits. */
+ body.mobile .tn-card .tn-card-option > select:is(:focus, :focus-visible),
+ body.mobile .tn-card .tn-card-option > .dropdown > .btn:is(:focus, :focus-visible) {
+ outline: none;
+ }
+
+ /* Carried by the row rather than the control, since a bare `select` can hold no pseudo-element
+ of its own. Same mark as `.tn-card-chevron`, which a pseudo-element cannot be given. */
+ .tn-card .tn-card-option:has(> :is(select, .dropdown))::after {
+ content: "";
+ flex-shrink: 0;
+ width: .9em;
+ height: .9em;
+ background-color: var(--muted-text-color);
+ -webkit-mask: var(--card-chevron) center / contain no-repeat;
+ mask: var(--card-chevron) center / contain no-repeat;
+ }
+
+ /* Laid out rather than flexed, so the name is given the width it asks for and the value takes
+ what is left. Flexed, the two gave way together and the name wrapped while the value, which
+ has an ellipsis to fall back on, kept its full width. */
+ .tn-card .tn-card-option:has(> :is(select, .dropdown)) {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ grid-template-areas: "title value chevron";
+ align-items: center;
+ column-gap: 8px;
+
+ /* The label stops being a box of its own, so the lines it holds become items of the grid.
+ Binding the text to the control is the `for` attribute's work, not the layout's. */
+ > .tn-card-option-label {
+ display: contents;
+ }
+
+ .tn-card-option-title {
+ grid-area: title;
+ }
+
+ > :is(select, .dropdown) {
+ grid-area: value;
+ }
+
+ /* Filling the track it was handed, so the value reads against the trailing edge and the
+ whole of the track answers a tap. */
+ > .dropdown > .btn {
+ flex: 1;
+ }
+
+ &::after {
+ grid-area: chevron;
+ }
+ }
+
+ /* Beside the label a sentence is left only a gutter to wrap in, and the value floats halfway
+ down whatever that wrapping makes. Given a row of its own it runs the full width instead. */
+ .tn-card .tn-card-option:has(> :is(select, .dropdown)):has(.tn-card-option-description) {
+ grid-template-areas:
+ "title value chevron"
+ "description description description";
+ /* The sentence stands off the row above by as much as the row stands off its edge. */
+ row-gap: var(--card-padding-block);
+
+ .tn-card-option-description {
+ grid-area: description;
+ }
}
}
diff --git a/apps/client/src/widgets/react/Card.tsx b/apps/client/src/widgets/react/Card.tsx
index c9d1f1c2b6..d8b387bb94 100644
--- a/apps/client/src/widgets/react/Card.tsx
+++ b/apps/client/src/widgets/react/Card.tsx
@@ -144,7 +144,7 @@ export function CardSection(props: {children: ComponentChildren} & CardSectionPr
data-no-contained-navigation={props.noContainedNavigation ? "" : undefined}
onClick={props.onAction}>
{props.children}
- <span className="tn-card-section-chevron bx bx-chevron-right" />
+ <span className="tn-card-section-chevron" />
</a>
: <section className={className}
style={style}
diff --git a/apps/client/src/widgets/react/master_detail.css b/apps/client/src/widgets/react/master_detail.css
index 4e9b4bea8e..ada577edad 100644
--- a/apps/client/src/widgets/react/master_detail.css
+++ b/apps/client/src/widgets/react/master_detail.css
@@ -130,6 +130,22 @@ body[dir="rtl"].mobile .modal.mobile-master-detail.mobile-transition-to-list {
text-overflow: ellipsis;
flex-grow: 1;
}
+
+ /* Follows the name it belongs to and takes the slack from there, so it stands beside the title
+ rather than at the far end, where the dialog's own close button is and where a press meant
+ for one would too easily land on the other. */
+ .tn-master-detail-page-actions {
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ gap: 4px;
+ margin-inline-end: auto;
+ }
+
+ /* The name gives up the slack, the actions after it having taken it on. */
+ &:has(.tn-master-detail-page-actions) .tn-master-detail-title {
+ flex-grow: 0;
+ }
}
@keyframes tn-master-detail-in-end {
diff --git a/apps/client/src/widgets/react/master_detail.tsx b/apps/client/src/widgets/react/master_detail.tsx
index a016869e30..197a5630f6 100644
--- a/apps/client/src/widgets/react/master_detail.tsx
+++ b/apps/client/src/widgets/react/master_detail.tsx
@@ -121,13 +121,20 @@ interface MasterDetailHeaderProps {
listIcon?: string;
/** The dialog's own actions, which belong to the list rather than to one page of it. */
listActions?: ComponentChildren;
+ /**
+ * Actions belonging to the page on show. The header carries the page's name here, so a control
+ * that explains or acts on the page as a whole reads beside it rather than inside the page.
+ */
+ pageActions?: ComponentChildren;
}
/**
* The header of a master-detail modal, in place of its static title (which master_detail.css hides):
* the way back and the name of what is on show, or the dialog's own name while the list is.
*/
-export function MasterDetailHeader({ inPage, onBack, backTitle, pageTitle, listTitle, listIcon, listActions }: MasterDetailHeaderProps) {
+export function MasterDetailHeader({
+ inPage, onBack, backTitle, pageTitle, listTitle, listIcon, listActions, pageActions
+}: MasterDetailHeaderProps) {
return (
<div class="tn-master-detail-header">
{inPage ? (
@@ -141,7 +148,9 @@ export function MasterDetailHeader({ inPage, onBack, backTitle, pageTitle, listT
{(inPage ? pageTitle : listTitle) && (
<h5 class="tn-master-detail-title">{inPage ? pageTitle : listTitle}</h5>
)}
- {!inPage && listActions}
+ {inPage
+ ? pageActions && <div class="tn-master-detail-page-actions">{pageActions}</div>
+ : listActions}
</div>
);
}
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.css b/apps/client/src/widgets/type_widgets/options/appearance.css
index fae40d6dbc..4214cd476f 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.css
+++ b/apps/client/src/widgets/type_widgets/options/appearance.css
@@ -30,12 +30,9 @@
color: var(--muted-text-color);
}
-/* The specimen is drawn at the user's own family and size, so it can outgrow the screen: on a narrow
- card it takes the line below the name instead of being carried off the edge. */
-.appearance-fonts .tn-card {
- container-type: inline-size;
-}
-
+/* The specimen is drawn at the user's own family and size, so it can outgrow the screen: it takes
+ the line below the name earlier than an ordinary option does. Measured against the card, which
+ `Card.css` makes a container. */
@container (max-width: 600px) {
.font-option {
flex-direction: column;
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx
index 9648d8f402..9e8c7781d1 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx
@@ -186,6 +186,9 @@ function UserInterface() {
{currentFamilyLabel}
</>}
mobileBottomSheet
+ // The card is a container, and so a backdrop root: left inside it the menu
+ // loses its blur and reads as a flat tint.
+ portalToBody
>
{THEME_FAMILIES.map(family => (
<FormListItem
@@ -537,7 +540,7 @@ function Font({ label, description, sizeDescription, fontFamilyOption, fontSizeO
>
<span className="font-option-preview">
<span className="font-option-specimen" style={{ fontFamily: getFontFamily(fontFamily ?? ""), fontSize: `${fontSize}%` }}>{displayLabel}</span>
- <span className="bx bx-chevron-right" />
+ <span className="tn-card-chevron" />
</span>
</OptionCardSection>
diff --git a/apps/client/src/widgets/type_widgets/options/backup.tsx b/apps/client/src/widgets/type_widgets/options/backup.tsx
index 2a3bf3e9bb..d611d7362b 100644
--- a/apps/client/src/widgets/type_widgets/options/backup.tsx
+++ b/apps/client/src/widgets/type_widgets/options/backup.tsx
@@ -420,7 +420,7 @@ export function BackupOptions() {
: t("backup.no_keyring")}
>
{passphrase.set ? (
- <>
+ <span className="tn-card-option-actions">
<Button
name="change-backup-password-button"
text={t("backup.change_password")}
@@ -431,7 +431,7 @@ export function BackupOptions() {
currentValue={encryptionEnabled}
onChange={(enabled) => enabled ? setEncryptionEnabled(true) : disableEncryption()}
/>
- </>
+ </span>
) : (
<Button
name="turn-on-backup-encryption-button"
diff --git a/apps/client/src/widgets/type_widgets/options/components/CheckboxList.css b/apps/client/src/widgets/type_widgets/options/components/CheckboxList.css
new file mode 100644
index 0000000000..621606cccf
--- /dev/null
+++ b/apps/client/src/widgets/type_widgets/options/components/CheckboxList.css
@@ -0,0 +1,12 @@
+/* A list of boxes rather than a bulleted list: it keeps no bullet and no room for one, so the first
+ box starts on the same rail as the text around it. */
+.tn-checkbox-list {
+ margin-bottom: 0;
+ padding-inline-start: 0;
+ column-width: var(--checkbox-list-column-width, 400px);
+ list-style-type: none;
+
+ > li + li {
+ margin-block-start: 6px;
+ }
+}
diff --git a/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx b/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx
index 582413ccfd..7615b92164 100644
--- a/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/CheckboxList.tsx
@@ -1,3 +1,5 @@
+import "./CheckboxList.css";
+
interface CheckboxListProps<T> {
values: T[];
keyProperty: keyof T;
@@ -26,7 +28,11 @@ export default function CheckboxList<T>({ values, keyProperty, titleProperty, di
}
return (
- <ul style={{ listStyleType: "none", marginBottom: 0, columnWidth: columnWidth ?? "400px" }}>
+ <ul
+ className="tn-checkbox-list"
+ // Handed over as a property rather than set outright, so that CSS can still reach it.
+ style={columnWidth ? { "--checkbox-list-column-width": columnWidth } : undefined}
+ >
{values.map(value => (
<li>
<label className="tn-checkbox">
diff --git a/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx b/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx
index 79270457c3..cc1bd90b17 100644
--- a/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/LocaleSelector.tsx
@@ -16,7 +16,12 @@ export function LocaleSelector({ id, locales, currentValue, onChange, defaultLoc
const currentValueWithDefault = currentValue ?? defaultLocale?.id ?? "";
const { activeLocale, processedLocales } = useProcessedLocales(locales, defaultLocale, currentValueWithDefault);
return (
- <Dropdown id={id} text={activeLocale?.name} mobileBottomSheet>
+ <Dropdown
+ id={id} text={activeLocale?.name} mobileBottomSheet
+ // The options card is a container, and so a backdrop root: left inside it the menu
+ // loses its blur and reads as a flat tint.
+ portalToBody
+ >
{processedLocales.map((locale, index) => (
(typeof locale === "object") ? (
<FormListItem
diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css
index e76aac93ae..136ae0b368 100644
--- a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css
+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css
@@ -116,20 +116,8 @@ body.experimental-feature-new-layout .options-page-header {
}
/* The name was all it carried, so it stands down rather than leaving an empty band above the
- first card. */
- .options-page-header-title-only:not(:has(.options-page-header-help)) {
- display: none;
- }
-
- /* All but the help button, which stays reachable — as a page action at the head of the content,
- though, rather than as a bar: the bar was there to hold the name. */
+ first card. Its help mark, where it had one, is handed to the header holding the name. */
.options-page-header-title-only {
- position: static;
- border-bottom: none;
- padding-block: 0;
-
- .options-page-header-main {
- justify-content: flex-end;
- }
+ display: none;
}
}
diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.spec.tsx b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.spec.tsx
index 035418c3e6..23895c6f6b 100644
--- a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.spec.tsx
@@ -1,3 +1,4 @@
+import { act } from "preact/test-utils";
import { describe, expect, it, vi } from "vitest";
import { renderInto } from "../../../../test/render";
@@ -11,7 +12,7 @@ vi.mock("../../../react/hooks", async (importOriginal) => ({
useNoteContext: () => ({ note: mocks.note })
}));
-import OptionsPageHeader from "./OptionsPageHeader";
+import OptionsPageHeader, { PageHelpSlot } from "./OptionsPageHeader";
const NOTE = { title: "Appearance", getIcon: () => "bx bx-palette" };
@@ -52,6 +53,25 @@ describe("OptionsPageHeader", () => {
expect(container.querySelector(".options-page-header-help")).not.toBeNull();
});
+ it("hands the help over to a host that has somewhere better for it, rather than drawing it", () => {
+ mocks.note = NOTE;
+ const taken: (string | undefined)[] = [];
+ let container!: HTMLElement;
+
+ // Handed over from an effect, which `renderInto` alone leaves pending.
+ act(() => {
+ container = renderInto(
+ <PageHelpSlot.Provider value={(helpUrl) => taken.push(helpUrl)}>
+ <OptionsPageHeader helpUrl="cbkrhQjrkKrh" />
+ </PageHelpSlot.Provider>
+ );
+ });
+
+ expect(taken).toContain("cbkrhQjrkKrh");
+ // Drawn in one place or the other, never in both.
+ expect(container.querySelector(".options-page-header-help")).toBeNull();
+ });
+
it("renders nothing at all before the note has arrived and with nothing else to show", () => {
mocks.note = undefined;
expect(renderInto(<OptionsPageHeader />).innerHTML).toBe("");
diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx
index 3655b63776..13fd230182 100644
--- a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx
+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx
@@ -1,11 +1,19 @@
import "./OptionsPageHeader.css";
import clsx from "clsx";
-import { ComponentChildren } from "preact";
+import { ComponentChildren, createContext } from "preact";
+import { useContext, useEffect } from "preact/hooks";
import HelpButton from "../../../react/HelpButton";
import { useNoteContext } from "../../../react/hooks";
+/**
+ * Where a page's help mark goes when the banner is no place for it: the phone's master-detail flow,
+ * whose own header carries the page name and so is where a mark explaining that page belongs. A
+ * host that offers this takes the mark; one that does not leaves the banner to draw it.
+ */
+export const PageHelpSlot = createContext<((helpUrl: string | undefined) => void) | undefined>(undefined);
+
interface OptionsPageHeaderProps {
/**
* Page-specific controls shown on the title row — e.g. a master enable toggle or, for the
@@ -44,6 +52,15 @@ export default function OptionsPageHeader({
const { note } = useNoteContext();
const shownTitle = title ?? note?.title;
const shownIcon = icon ?? note?.getIcon();
+ const liftHelp = useContext(PageHelpSlot);
+
+ // Handed over for as long as this page is the one on show, and taken back when it is not.
+ useEffect(() => {
+ if (!liftHelp) return;
+
+ liftHelp(helpUrl);
+ return () => liftHelp(undefined);
+ }, [ liftHelp, helpUrl ]);
// Nothing to render: the note isn't available yet and the page provided no content.
if (!shownTitle && !actions && !below) return null;
@@ -59,9 +76,8 @@ export default function OptionsPageHeader({
<div className="options-page-header-titles">
<span className={`options-page-header-icon ${shownIcon}`} aria-hidden="true" />
<h2 className="options-page-header-title">{shownTitle}</h2>
- {/* Classed so it can be told from the name it stands beside: on a
- phone the name moves into the dialog's header and this stays. */}
- {helpUrl && <HelpButton className="options-page-header-help" helpPage={helpUrl} />}
+ {helpUrl && !liftHelp &&
+ <HelpButton className="options-page-header-help" helpPage={helpUrl} />}
</div>
)}
{actions && <div className="options-page-header-actions">{actions}</div>}
diff --git a/apps/client/src/widgets/type_widgets/options/database.css b/apps/client/src/widgets/type_widgets/options/database.css
index 6ff0a35484..a44b60b20c 100644
--- a/apps/client/src/widgets/type_widgets/options/database.css
+++ b/apps/client/src/widgets/type_widgets/options/database.css
@@ -1,12 +1,3 @@
-/* Facts, not controls: unlike the buttons the card rows are built around, a value gives way when
- the line runs short, and a path breaks wherever it must rather than widening the card. */
-.database-info .database-info-value {
- flex-shrink: 1;
- min-width: 0;
- text-align: end;
- overflow-wrap: anywhere;
-}
-
/* The notice sits above the cards it precedes, so the gap belongs under it. */
.admonition.start-over-pending {
margin-bottom: 16px;
diff --git a/apps/client/src/widgets/type_widgets/options/database.spec.tsx b/apps/client/src/widgets/type_widgets/options/database.spec.tsx
index 68d28e8466..6e2a8ed95c 100644
--- a/apps/client/src/widgets/type_widgets/options/database.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/database.spec.tsx
@@ -168,7 +168,7 @@ afterEach(() => {
describe("what the database is", () => {
/** The facts of the info card, in the order the card states them. */
function infoValues() {
- return [ ...container.querySelectorAll(".database-info .database-info-value") ]
+ return [ ...container.querySelectorAll(".database-info .tn-card-option-value") ]
.map((value) => value.textContent);
}
diff --git a/apps/client/src/widgets/type_widgets/options/database.tsx b/apps/client/src/widgets/type_widgets/options/database.tsx
index 3af91d312a..dcc67e2f1f 100644
--- a/apps/client/src/widgets/type_widgets/options/database.tsx
+++ b/apps/client/src/widgets/type_widgets/options/database.tsx
@@ -109,7 +109,7 @@ function DatabaseInfo({ refreshToken }: { refreshToken: number }) {
return (
<Card className="database-info" heading={t("database.info")}>
<OptionCardSection label={t("database.info_location")}>
- <span className="database-info-value">
+ <span className="tn-card-option-value">
{/* Revealed rather than opened: a file manager is what a path is useful in,
and the database's own reader is Trilium. Where there is no path, the
storage holding it is named instead — nothing there can be pointed at. */}
@@ -120,7 +120,7 @@ function DatabaseInfo({ refreshToken }: { refreshToken: number }) {
</OptionCardSection>
<OptionCardSection label={t("database.info_content")}>
- <span className="database-info-value">
+ <span className="tn-card-option-value">
{t("database.info_notes", { count: info.noteCount })}
{", "}
{t("database.info_attachments", { count: info.attachmentCount })}
@@ -128,13 +128,13 @@ function DatabaseInfo({ refreshToken }: { refreshToken: number }) {
</OptionCardSection>
<OptionCardSection label={t("database.info_created")}>
- <span className="database-info-value">
+ <span className="tn-card-option-value">
{formatDateTime(info.utcDateCreated, "long", "none")}
</span>
</OptionCardSection>
<OptionCardSection label={t("database.info_size")}>
- <span className="database-info-value">{formatSize(info.sizeBytes)}</span>
+ <span className="tn-card-option-value">{formatSize(info.sizeBytes)}</span>
</OptionCardSection>
{/* Absent where backups are not kept at all: the browser build's one backup is a
@@ -161,7 +161,7 @@ function BackupStanding({ refreshToken }: { refreshToken: number }) {
<OptionCardSection label={t("database.info_backup")}>
{/* The whole value is the way to the page that acts on it: this row states how the
backups stand, and everything else about them is done there. */}
- <span className="database-info-value">
+ <span className="tn-card-option-value">
<a className="tn-link" href={BACKUP_PAGE_LINK}>
{summarizeBackups(backups.backups) ?? t("database.info_no_backup")}
</a>
diff --git a/apps/client/src/widgets/type_widgets/options/etapi.css b/apps/client/src/widgets/type_widgets/options/etapi.css
index fcdc2d2358..2415674283 100644
--- a/apps/client/src/widgets/type_widgets/options/etapi.css
+++ b/apps/client/src/widgets/type_widgets/options/etapi.css
@@ -18,8 +18,3 @@
color: var(--muted-text-color);
font-size: 13px;
}
-
-.etapi-token-actions {
- display: flex;
- gap: 4px;
-}
diff --git a/apps/client/src/widgets/type_widgets/options/etapi.tsx b/apps/client/src/widgets/type_widgets/options/etapi.tsx
index c6e2f740ad..4a55fa4acd 100644
--- a/apps/client/src/widgets/type_widgets/options/etapi.tsx
+++ b/apps/client/src/widgets/type_widgets/options/etapi.tsx
@@ -132,7 +132,7 @@ function TokenList({ tokens }: { tokens: EtapiToken[] }) {
description={formatDateTime(utcDateCreated)}
>
{etapiTokenId && (
- <span className="etapi-token-actions">
+ <span className="tn-card-option-actions">
<ActionButton
icon="bx bx-edit-alt"
text={t("etapi.rename_token")}
diff --git a/apps/client/src/widgets/type_widgets/options/llm.css b/apps/client/src/widgets/type_widgets/options/llm.css
index 98b8e07776..de3f544d35 100644
--- a/apps/client/src/widgets/type_widgets/options/llm.css
+++ b/apps/client/src/widgets/type_widgets/options/llm.css
@@ -4,11 +4,6 @@
gap: 0.5em;
}
-.llm-provider-actions {
- display: flex;
- gap: 4px;
-}
-
.llm-add-provider {
text-align: end;
}
diff --git a/apps/client/src/widgets/type_widgets/options/llm.tsx b/apps/client/src/widgets/type_widgets/options/llm.tsx
index a5a77d4b3f..92d01f60d8 100644
--- a/apps/client/src/widgets/type_widgets/options/llm.tsx
+++ b/apps/client/src/widgets/type_widgets/options/llm.tsx
@@ -290,7 +290,7 @@ function ProviderList({ providers, onEdit, onDelete }: ProviderListProps) {
? t("llm.provider_model_count", { count: modelCount })
: providerType?.name || provider.provider}
>
- <span className="llm-provider-actions">
+ <span className="tn-card-option-actions">
<ActionButton
icon="bx bx-edit"
text={t("llm.edit_provider")}
diff --git a/apps/client/src/widgets/type_widgets/options/media.spec.tsx b/apps/client/src/widgets/type_widgets/options/media.spec.tsx
index a4fa385058..abff8e0719 100644
--- a/apps/client/src/widgets/type_widgets/options/media.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/media.spec.tsx
@@ -128,16 +128,12 @@ function titleOf(row: Element): string | undefined {
return label
? label.childNodes[0]?.textContent ?? undefined
- : row.querySelector(".image-compression-section-title")?.textContent ?? undefined;
+ : row.querySelector(".tn-card-option-title")?.textContent ?? undefined;
}
-/** The sentence beneath a row's title, from whichever of the two kinds of row it is. */
+/** The sentence beneath a row's title. Both kinds of row are built on the same option row now. */
function describes(title: string): string | undefined {
- const row = rowOrFail(title);
-
- return row.querySelector(".tn-card-option-description")?.textContent
- ?? row.querySelector(".image-compression-section-description")?.textContent
- ?? undefined;
+ return rowOrFail(title).querySelector(".tn-card-option-description")?.textContent ?? undefined;
}
function rowOrFail(title: string): HTMLElement {
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.css b/apps/client/src/widgets/type_widgets/options/shortcuts.css
index df93ba060d..59eef20ae6 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.css
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.css
@@ -17,6 +17,8 @@
}
.shortcut-header-filter {
+ /* The row measures itself, standing outside the cards and out of reach of their container. */
+ container-type: inline-size;
display: flex;
flex-wrap: wrap;
align-items: center;
@@ -27,10 +29,8 @@
flex: 1;
}
- .dropdown,
- > .btn {
+ > .dropdown {
flex: 0 0 auto;
- white-space: nowrap;
}
/* Highlight the filter button while a filter is applied. */
@@ -39,6 +39,29 @@
}
}
+/* The page's own actions, held as one item so they travel together when the row breaks. */
+.shortcut-header-actions {
+ display: flex;
+ flex-shrink: 0;
+ gap: 0.5em;
+
+ > .btn {
+ white-space: nowrap;
+ }
+}
+
+/* Too little room for one line: the filter keeps the first with its button, and the actions take
+ the second, sharing it evenly between them. */
+@container (max-width: 500px) {
+ .shortcut-header-actions {
+ flex-basis: 100%;
+
+ > .btn {
+ flex: 1;
+ }
+ }
+}
+
/* The cards are grouped one level in, out of reach of the page's own stacking rule. */
.shortcuts-options-section {
display: flex;
@@ -161,15 +184,17 @@
}
}
- /* A card option stacks itself only for a button or a slider, and the editor is neither. */
- body.mobile & {
- .tn-card-option {
- flex-direction: column;
- align-items: stretch;
- }
-
+ /* The card stacks the row at this width on its own, so the chips read from the leading edge
+ rather than staying pushed against the trailing one. */
+ @container (max-width: 500px) {
.shortcut-editor {
justify-content: flex-start;
}
+
+ /* Read from the leading edge, the recorder stands after however many chips the row holds,
+ so there is no column left for the empty slot to hold open — only a hole before it. */
+ .shortcut-revert-slot:empty {
+ display: none;
+ }
}
}
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.editing.spec.tsx b/apps/client/src/widgets/type_widgets/options/shortcuts.editing.spec.tsx
index 165f279965..7edf33a265 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.editing.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.editing.spec.tsx
@@ -108,11 +108,20 @@ function rowFor(name: string) {
.find((row) => row.querySelector(".tn-card-option-label")?.textContent?.includes(name));
}
-/** Picks one of the filter menu's entries. The menu is only built once the dropdown is opened. */
+/**
+ * Picks one of the filter menu's entries. The menu is only built once the dropdown is opened, and
+ * it is carried out to the body from there, so it is looked for outside the page rather than in it.
+ */
async function chooseFilter(index: number) {
- await act(async () => host.querySelector<HTMLElement>(".header-stub .dropdown button")?.click());
+ const toggle = host.querySelector<HTMLElement>(".header-stub .dropdown button");
+
+ // The menu is only put into the body once the toggle is pressed, which in a browser means the
+ // pointer going down before the click. `click()` alone sends no such press, and Bootstrap then
+ // opens against a menu that is not there yet.
+ await act(async () => void toggle?.dispatchEvent(new Event("pointerdown", { bubbles: true })));
+ await act(async () => toggle?.click());
- const items = [ ...host.querySelectorAll<HTMLElement>(".header-stub .dropdown-menu .dropdown-item") ];
+ const items = [ ...document.body.querySelectorAll<HTMLElement>(".dropdown-menu .dropdown-item") ];
await act(async () => items[index]?.click());
}
diff --git a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
index c6b37f0e3b..c85ed79b4b 100644
--- a/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
+++ b/apps/client/src/widgets/type_widgets/options/shortcuts.tsx
@@ -140,6 +140,9 @@ export default function ShortcutSettings() {
title={t("shortcuts.filter")}
dropdownRef={filterDropdownRef}
dropdownContainerClassName={isMobile() ? "mobile-bottom-menu" : undefined}
+ // The row is a container, and so a backdrop root: left inside it the
+ // menu loses its blur and reads as a flat tint.
+ portalToBody
>
<FilterContent
activeFilter={activeFilter}
@@ -150,19 +153,23 @@ export default function ShortcutSettings() {
/>
</Dropdown>
- <Button
- text={t("shortcuts.reload_app")}
- // Called rather than handed over: its one argument is the reason to be
- // logged for the reload, and passed straight to the button that would
- // have been the click event.
- onClick={() => reloadFrontendApp()}
- size="micro"
- />
- <Button
- text={t("shortcuts.set_all_to_default")}
- onClick={resetShortcuts}
- size="micro"
- />
+ {/* Held together, so that a narrow page can put the pair on a line of
+ their own under the filter rather than breaking them apart. */}
+ <div className="shortcut-header-actions">
+ <Button
+ text={t("shortcuts.reload_app")}
+ // Called rather than handed over: its one argument is the reason to
+ // be logged for the reload, and passed straight to the button that
+ // would have been the click event.
+ onClick={() => reloadFrontendApp()}
+ size="micro"
+ />
+ <Button
+ text={t("shortcuts.set_all_to_default")}
+ onClick={resetShortcuts}
+ size="micro"
+ />
+ </div>
</div>
}
/>
diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.tsx b/apps/client/src/widgets/type_widgets/options/text_notes.tsx
index ff09a7e9d0..d2f7de1ecb 100644
--- a/apps/client/src/widgets/type_widgets/options/text_notes.tsx
+++ b/apps/client/src/widgets/type_widgets/options/text_notes.tsx
@@ -462,7 +462,12 @@ function HeadingStyleSelector({ currentValue, onChange }: { currentValue: string
const currentStyle = HEADING_STYLES.find(s => s.value === currentValue) ?? HEADING_STYLES[0];
return (
- <Dropdown text={t(currentStyle.labelKey)} mobileBottomSheet>
+ <Dropdown
+ text={t(currentStyle.labelKey)} mobileBottomSheet
+ // The options card is a container, and so a backdrop root: left inside it the menu
+ // loses its blur and reads as a flat tint.
+ portalToBody
+ >
{HEADING_STYLES.map(({ value, labelKey }) => (
<FormListItem
key={value}