Turn folder view into a select box style details/summary driven picker to save space

This commit is contained in:
mrkmntal 2026-11-16 10:29:53 -05:00
commit c5c8ce80b2
6 changed files with 332 additions and 121 deletions

View file

@ -60,7 +60,9 @@ Re-filing a note has **three entry points, and they are not equivalent**. `File
Drag-and-drop is the third path and **does work on touch** — this was previously documented here as impossible, which was wrong. On a touch screen the gesture is a *long press* rather than an immediate drag, verified working on iOS 18.7 / Firefox 156. It is not universal: it requires JS, and in engines without touch support for HTML5 drag the same gesture scrolls the sidebar instead. So a phone's three paths are all live; do not assume drag is desktop-only when adding UI around it.
Two touch-specific details follow from the long press. `.note-item` sets `-webkit-touch-callout: none` so Safari's long-press menu does not compete with the gesture, while leaving `user-select` alone so preview text stays copyable. And the `dragstart` text-selection guard in `app.js` is gated on `matchMedia('(hover: hover)')` — a long press creates a selection *before* the drag starts, so an ungated guard cancels the gesture itself. `.folder-nav` is `position: sticky` inside the scrolling `.sidebar` on desktop, because nothing auto-scrolls a nested overflow container mid-drag and the folders are the drop targets. On mobile, the sidebar does not scroll; instead `.folder-nav` and `.note-list` each scroll independently within their own bounded areas, and the pull-tab toggle stays visible above the scrolling folder list.
The folder nav is a one-row `<details class="folder-picker">` disclosure: the `<summary>` names the current folder and the existing `<ul id="folder-nav-list">` is its dropdown content. The list is always the same markup the drag handlers look for, so counts, active styling, and every `li[data-drop-folder]` drop target stay in one place. `dragstart` sets the picker's `open` property (and marks the sidebar `dragging-note`, which overrides the collapsed state), so the drop targets appear mid-gesture on mouse and touch alike; `endNoteDrag` closes it again. The list is absolutely positioned, so opening it never pushes the note list down.
Two touch-specific details follow from the long press. `.note-item` sets `-webkit-touch-callout: none` so Safari's long-press menu does not compete with the gesture, while leaving `user-select` alone so preview text stays copyable. And the `dragstart` text-selection guard in `app.js` is gated on `matchMedia('(hover: hover)')` — a long press creates a selection *before* the drag starts, so an ungated guard cancels the gesture itself. `.folder-nav-container` is `position: sticky` inside the scrolling `.sidebar` on desktop, because nothing auto-scrolls a nested overflow container mid-drag. The picker summary is one row; `.folder-nav` is an absolutely positioned dropdown with its own `max-height` and scroll. On mobile, the sidebar does not scroll; the note list scrolls independently while the dropdown overlays it. The old pull-tab is gone; `View → Hide/Show Folder Nav` is the collapse control.
Neither entry point may carry `.desktop-only`. That class hides at `max-width: 600px`, and the bar is already hidden above 600px by a `min-width` query; adding the class composes to hiding it at *every* width and phones lose re-filing entirely. That shipped once. No Rust test can observe `display: none`, so `move_entry_points_are_not_desktop_only` pins the markup contract instead. All forms post the same `folder` field, where an empty value means the root. See §11 for the rename rule that makes a move destructive if done any other way, and for why user-supplied folder names force the flyout's `max-width`/wrapping.

View file

@ -57,6 +57,7 @@ app from making that request.
- **File-based storage** — notes are persisted as Markdown files in `notes/`
- **Virtual folders** — organize notes into folders without real directories; folders are encoded as `[Folder]uuid.md` filename prefixes
- **Move notes between folders** — drag a note onto a folder, use `File → Move to Folder…`, or the Move control in the editor on a phone
- **One-row folder picker** — the sidebar shows the current folder; the folder list opens on demand and automatically while dragging, so it stays droppable however long the note list grows
- **Per-note exports** — download Markdown or self-contained themed HTML, or print/save the themed note as PDF
- **40 built-in themes** — including KDE Breeze, Blueberry Professional, classic desktop homages, distro-inspired palettes, warm neutrals, and more
- **Markdown extras** — tables, tasklists, strikethrough, and footnotes via `pulldown-cmark`
@ -95,9 +96,9 @@ Root notes (no folder) keep the plain `uuid.md` format. Folders exist only when
**Creating a folder:** click `+ New Folder` in the sidebar, type a name, and the app creates a new note in that folder and opens it.
**Filtering:** click a folder name in the sidebar to see only that folder's notes. Click **All Notes** to see everything grouped by folder. When a folder is active, **File → New Note** creates notes in that folder.
**Filtering:** choose a folder from the sidebar's folder picker to see only that folder's notes. Choose **All Notes** to see everything grouped by folder. When a folder is active, **File → New Note** creates notes in that folder.
**Moving a note between folders:** drag it from the sidebar onto a folder, pick `File → Move to Folder…`, or use the Move control under the editor on a phone. Dropping a note on **All Notes** — or choosing **Unfiled** — takes it back out of its folder.
**Moving a note between folders:** drag it from the sidebar onto a folder (the folder list opens while you drag), pick `File → Move to Folder…`, or use the Move control under the editor on a phone. Dropping a note on **All Notes** — or choosing **Unfiled** — takes it back out of its folder.
A move renames the file: `[Work]uuid.md` becomes `[Home]uuid.md`. The note's id is left untouched, so links to it keep working, and its modified time is not bumped, since re-filing is not an edit.

View file

@ -394,10 +394,10 @@ fn render_menu_bar(
}
}
}
// Available at every width. The folder nav is a sidebar
// sub-section, not a top-level pane, so collapsing it is
// useful on mobile too — the pull-tab button is the other
// entry point and shares this same state.
// Available at every width. The folder picker is a
// sidebar sub-section, not a top-level pane, so hiding
// it is useful on mobile too. Since the one-row picker
// replaced the pull-tab, this menu is the only control.
li {
button x-on:click="toggleFolderNav()"
x-bind:class="{ 'active-view': folderNavCollapsed }"
@ -553,6 +553,14 @@ fn render_sidebar(
}
}
// The one-row picker shows the current folder. Its count follows the same
// rule as the list badges: the All Notes total, or the open folder's count.
let active_label = active_folder.unwrap_or("All Notes");
let active_count = match active_folder {
None => notes.len(),
Some(folder) => by_folder.get(folder).map(|v| v.len()).unwrap_or(0),
};
html! {
aside class={"sidebar" (active)} data-tab-pane="notes"
x-bind:class="{ 'mobile-active': tab === 'notes' }" {
@ -563,33 +571,37 @@ fn render_sidebar(
}
div class="folder-nav-container"
x-bind:class="{ 'collapsed': folderNavCollapsed }" {
button type="button" class="folder-nav-toggle"
x-on:click="toggleFolderNav()"
x-bind:aria-expanded="(!folderNavCollapsed).toString()"
aria-controls="folder-nav-list"
aria-label="Toggle folder navigation" {
span class="folder-nav-toggle-icon" aria-hidden="true" { "▾" }
}
ul id="folder-nav-list" class="folder-nav" {
// An empty drop folder is the root: dropping a note on "All
// Notes" un-files it, which is the only way back out of a
// folder once every note has left it.
li class={"nav-item" (if active_folder.is_none() { " active" } else { "" })}
data-drop-folder="" {
a href=(base.url("/")) {
span class="nav-label" { "All Notes" }
@if show_nav_count(active_folder, None) {
span class="nav-count" { (notes.len()) }
// A native disclosure keeps folder navigation working without
// JavaScript. The list is the same markup the drag handlers and
// the sidebar refresh look for, so there is one source of truth
// for folder links, counts, and drop targets.
details class="folder-picker" {
summary class="folder-picker-summary" title=(active_label) {
span class="folder-picker-label" { (active_label) }
span class="nav-count" { (active_count) }
span class="folder-picker-chevron" aria-hidden="true" { "▾" }
}
ul id="folder-nav-list" class="folder-nav" {
// An empty drop folder is the root: dropping a note on
// "All Notes" un-files it, which is the only way back
// out of a folder once every note has left it.
li class={"nav-item" (if active_folder.is_none() { " active" } else { "" })}
data-drop-folder="" {
a href=(base.url("/")) {
span class="nav-label" { "All Notes" }
@if show_nav_count(active_folder, None) {
span class="nav-count" { (notes.len()) }
}
}
}
}
@for folder in folders {
li class={"nav-item" (if active_folder == Some(folder.as_str()) { " active" } else { "" })}
data-drop-folder=(folder) {
a href=(folder_url(base, folder)) {
span class="nav-label" { (folder) }
@if show_nav_count(active_folder, Some(folder)) {
span class="nav-count" { (by_folder.get(folder).map(|v| v.len()).unwrap_or(0)) }
@for folder in folders {
li class={"nav-item" (if active_folder == Some(folder.as_str()) { " active" } else { "" })}
data-drop-folder=(folder) {
a href=(folder_url(base, folder)) title=(folder) {
span class="nav-label" { (folder) }
@if show_nav_count(active_folder, Some(folder)) {
span class="nav-count" { (by_folder.get(folder).map(|v| v.len()).unwrap_or(0)) }
}
}
}
}

View file

@ -18,8 +18,8 @@ function app() {
// the highlight follows the pointer instead of accumulating on every item
// the cursor sweeps across.
_dropTarget: null,
// Whether the folder navigation is collapsed. Shared between the mobile
// pull-tab button and the View menu toggle so they stay in sync.
// Whether the folder picker is hidden. Controlled by the View menu and
// persisted so the sidebar keeps the preferred layout.
folderNavCollapsed: false,
init() {
@ -31,6 +31,12 @@ function app() {
if (this.openMenu && menuBar && !menuBar.contains(event.target)) {
this.closeMenus();
}
// The folder picker is a native <details>, so its summary toggles it
// with or without JS. This only adds close-on-outside-click.
const picker = document.querySelector('.folder-picker');
if (picker && picker.open && !picker.contains(event.target)) {
picker.open = false;
}
};
document.addEventListener('click', this._onDocClick);
@ -92,6 +98,15 @@ function app() {
item.classList.add('dragging');
event.dataTransfer.effectAllowed = 'move';
event.dataTransfer.setData('text/plain', id);
// Reveal the folder picker as the drop target. This is the same
// long-press gesture on touch, so it must work there too: the class
// also overrides a collapsed picker in CSS, and opening the native
// disclosure is what makes the list's items live drop targets.
const sidebar = document.querySelector('.sidebar');
if (sidebar) sidebar.classList.add('dragging-note');
const picker = document.querySelector('.folder-picker');
if (picker) picker.open = true;
};
this._onDragOver = (event) => {
@ -184,6 +199,12 @@ function app() {
document.querySelectorAll('.note-item.dragging').forEach((el) => {
el.classList.remove('dragging');
});
const sidebar = document.querySelector('.sidebar');
if (sidebar) sidebar.classList.remove('dragging-note');
// Back to the one-row picker after every drag, including an abandoned
// one. The user reopens it with the summary when they want to browse.
const picker = document.querySelector('.folder-picker');
if (picker) picker.open = false;
},
/// Posts a re-file for `id` and reloads so the sidebar reflects the move.
@ -277,6 +298,8 @@ function app() {
this.folderNavCollapsed = !this.folderNavCollapsed;
this._saveFolderNavPreference(this.folderNavCollapsed);
if (this.folderNavCollapsed) {
const picker = document.querySelector('.folder-picker');
if (picker) picker.open = false;
this.refreshSidebarToAllNotes();
}
},
@ -307,9 +330,10 @@ function app() {
/// Refresh the sidebar to the All Notes view without navigating away.
///
/// Fetches the server-rendered index page and swaps in the folder nav,
/// note list, toolbar folder field, and status count. The editor pane and
/// note form are untouched, so unsaved edits survive.
/// Fetches the server-rendered index page and swaps in the folder picker's
/// summary and list, the note list, the File menu's New Note folder field,
/// and the status count. The editor pane and note form are untouched, so
/// unsaved edits survive.
refreshSidebarToAllNotes() {
const base = window.__BASE_PATH__ || '';
const searchInput = document.querySelector('.search-form input[name="q"]');
@ -322,13 +346,25 @@ function app() {
const doc = new DOMParser().parseFromString(html, 'text/html');
if (!doc.querySelector('.sidebar')) return; // not the app page
// Swap the folder nav list
// Swap the picker's summary (current folder label and count)
const newSummary = doc.querySelector('.folder-picker-summary');
const oldSummary = document.querySelector('.folder-picker-summary');
if (newSummary && oldSummary) {
oldSummary.innerHTML = newSummary.innerHTML;
oldSummary.title = newSummary.title;
}
// Swap the folder list
const newNav = doc.querySelector('#folder-nav-list');
const oldNav = document.querySelector('#folder-nav-list');
if (newNav && oldNav) {
oldNav.innerHTML = newNav.innerHTML;
}
// Return the picker to its one-row state.
const picker = document.querySelector('.folder-picker');
if (picker) picker.open = false;
// Swap the note list
const newList = doc.querySelector('.note-list');
const oldList = document.querySelector('.note-list');
@ -336,11 +372,18 @@ function app() {
oldList.innerHTML = newList.innerHTML;
}
// Update the toolbar's hidden folder field
const newFolderInput = doc.querySelector('.toolbar input[name="folder"]');
const oldFolderInput = document.querySelector('.toolbar input[name="folder"]');
if (newFolderInput && oldFolderInput) {
oldFolderInput.value = newFolderInput.value;
// Keep the File menu's New Note form in sync. The All Notes view
// emits no hidden folder input, so remove the old one rather than
// leaving New Note pointed at the folder we just left.
const newFolderInput = doc.querySelector(
'.file-menu-dropdown form[action$="/notes"] input[name="folder"]'
);
const oldFolderInput = document.querySelector(
'.file-menu-dropdown form[action$="/notes"] input[name="folder"]'
);
if (oldFolderInput) {
if (newFolderInput) oldFolderInput.value = newFolderInput.value;
else oldFolderInput.remove();
}
// Update the status bar note count

View file

@ -515,12 +515,12 @@ button, input, select, textarea {
}
/* Folder Navigation */
/* Sticky so the folders stay visible, and droppable, however long the note
list grows — `.sidebar` is the scroll container and the nav sits above the
list inside it. Nothing auto-scrolls a nested overflow container mid-drag,
so without this the drag targets simply scroll out of reach.
/* One row shows the current folder; the list opens on demand. Sticky on
desktop so the picker, and its drop targets, stay reachable however long
the note list grows — `.sidebar` is the scroll container and the picker
sits above the list inside it.
Needs its own background because it now overlays the scrolling note items.
Needs its own background because it overlays the scrolling note items.
The z-index is scoped to the sidebar and safe under the stacking-context
rule in AGENTS.md §7: no menu dropdowns live in here to trap. */
.folder-nav-container {
@ -528,56 +528,118 @@ button, input, select, textarea {
top: 0;
z-index: 2;
background-color: var(--app-bg);
/* `.sidebar` is a flex column, so without this the nav can be squeezed by
a long note list — and a squeezed sticky bar clips its own folder names,
which are the drop target labels. */
/* `.sidebar` is a flex column, so without this the picker can be squeezed
by a long note list — and a squeezed row clips the current folder name. */
flex-shrink: 0;
transition: background-color 0.15s ease, border-color 0.15s ease;
}
.folder-nav {
list-style: none;
margin: 0;
padding: 8px;
/* Anchors the absolutely positioned dropdown just below the summary. */
.folder-picker {
position: relative;
}
.folder-picker-summary {
display: flex;
flex-direction: column;
gap: 2px;
border-bottom: 1px solid var(--ui-border);
}
/* Pull-tab toggle — hidden on desktop, shown on mobile */
.folder-nav-toggle {
display: none;
width: 100%;
min-height: 44px;
align-items: center;
justify-content: center;
background: var(--app-bg);
border: none;
gap: 8px;
min-height: 40px;
padding: 8px 12px;
border-bottom: 1px solid var(--ui-border);
color: var(--app-fg);
opacity: 0.6;
cursor: pointer;
user-select: none;
font-size: 13px;
font-weight: 500;
list-style: none;
transition: background-color 0.15s ease, border-color 0.15s ease;
}
/* Hide the native disclosure marker; the chevron carries the same signal. */
.folder-picker-summary::-webkit-details-marker {
display: none;
}
.folder-picker-summary::marker {
content: "";
}
.folder-picker-summary:hover {
background-color: var(--ui-hover);
}
/* Keep the count pill from blending into the row's hover background. */
.folder-picker-summary:hover .nav-count {
background-color: var(--app-bg);
}
.folder-picker-summary:focus-visible {
outline: 2px solid var(--ansi-4);
outline-offset: -2px;
}
.folder-picker-label {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.folder-picker-chevron {
flex-shrink: 0;
transition: opacity 0.15s ease;
}
.folder-nav-toggle:hover {
opacity: 0.8;
}
.folder-nav-toggle-icon {
font-size: 18px;
font-size: 12px;
line-height: 1;
opacity: 0.6;
transition: transform 0.15s ease;
}
/* Collapsed state — hides the folder list but keeps the toggle visible */
.folder-nav-container.collapsed .folder-nav {
.folder-picker[open] .folder-picker-chevron {
transform: rotate(180deg);
}
/* The dropdown reuses the nav list, so counts, active styling, and drag
targets stay in one place. Absolute positioning keeps opening it from
pushing the note list down. */
.folder-nav {
position: absolute;
top: 100%;
left: 0;
right: 0;
z-index: 3;
display: flex;
flex-direction: column;
gap: 2px;
list-style: none;
margin: 0;
padding: 8px;
max-height: min(60vh, 420px);
overflow-y: auto;
-webkit-overflow-scrolling: touch;
overscroll-behavior: contain;
background-color: var(--app-bg);
border-bottom: 1px solid var(--ui-border);
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
/* A closed disclosure hides its content, but pin it explicitly so an author
`display` rule can never leak the list out. */
.folder-picker:not([open]) .folder-nav {
display: none;
}
.folder-nav-container.collapsed .folder-nav-toggle-icon {
transform: rotate(180deg);
/* Hidden from the View menu. During a drag the drop targets are the point, so
reveal the container even when collapsed — without the summary, so the note
list is not pushed down mid-gesture. */
.folder-nav-container.collapsed {
display: none;
}
.sidebar.dragging-note .folder-nav-container.collapsed {
display: block;
}
.sidebar.dragging-note .folder-nav-container.collapsed .folder-picker-summary {
display: none;
}
.nav-item a {
@ -601,7 +663,17 @@ button, input, select, textarea {
font-weight: 600;
}
/* Long folder names get one line with an ellipsis; the `title` attribute on
the link carries the full name on hover. */
.nav-label {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.nav-count {
flex-shrink: 0;
font-size: 11px;
opacity: 0.6;
background-color: var(--ui-hover);
@ -1842,30 +1914,25 @@ button, input, select, textarea {
min-height: 44px;
}
.folder-nav-toggle {
display: flex;
}
/* Independent scrolling: folder nav and note list each scroll within
their own area. The sidebar itself does not scroll on mobile. The
pull-tab button stays visible above the scrolling folder list. */
/* The picker is a single row, so only the note list needs an independent
scroll area. The dropdown overlays the note list and scrolls itself. */
.sidebar {
overflow: hidden;
}
.folder-nav-container {
position: static;
display: flex;
flex-direction: column;
max-height: 40%;
position: relative;
flex-shrink: 0;
}
.folder-picker-summary {
min-height: 44px;
padding: 10px 12px;
font-size: 14px;
}
.folder-nav {
overflow-y: auto;
flex: 1;
min-height: 0;
-webkit-overflow-scrolling: touch;
max-height: 50dvh;
padding: 8px;
}

View file

@ -1093,6 +1093,33 @@ async fn sidebar_note_items_and_folder_items_carry_drag_hooks() {
);
}
/// The folder list is a dropdown now, so drag must reveal it before the user
/// can drop. That is JS on both mouse and touch, hence a source/CSS contract
/// test rather than a rendered-markup one.
#[tokio::test]
async fn dragging_a_note_reveals_the_folder_picker() {
let f = Fixture::provisioned("folder-picker-drag");
let (status, body) = f.get_authed("/").await;
assert_eq!(status, StatusCode::OK);
assert!(
body.contains("dragging-note"),
"the drag code should mark the sidebar"
);
assert!(
body.contains("picker.open = true"),
"dragstart should open the folder picker for dropping"
);
assert!(
body.contains("picker.open = false"),
"dragend should return the picker to one row"
);
assert!(
body.contains(".sidebar.dragging-note .folder-nav-container.collapsed"),
"a collapsed picker must still be revealed as a drop target"
);
}
/// Desktop re-files through File > Move to Folder…. Each entry is its own form
/// posting to `/notes/:id/move`, so a click is a real POST and no JavaScript
/// performs the move.
@ -1358,12 +1385,11 @@ async fn sidebar_shows_folder_navigation() {
assert!(body.contains("nav-count"), "should show note counts");
}
/// The folder nav is wrapped in `.folder-nav-container` with a pull-tab toggle
/// button. The toggle must be present in the markup at every width (CSS hides
/// it on desktop) so mobile users can collapse/expand the folder list.
/// The folder nav is a one-row picker: a native disclosure whose summary shows
/// the current folder, with the existing list as its dropdown.
#[tokio::test]
async fn folder_nav_container_has_toggle_button() {
let f = Fixture::provisioned("folder-nav-toggle");
async fn folder_nav_is_a_one_row_picker() {
let f = Fixture::provisioned("folder-nav-picker");
f.post_authed("/folders", "name=Alpha").await;
let (status, body) = f.get_authed("/").await;
@ -1371,24 +1397,58 @@ async fn folder_nav_container_has_toggle_button() {
assert!(
body.contains("class=\"folder-nav-container\""),
"the folder nav should be wrapped in .folder-nav-container"
"the picker should stay inside .folder-nav-container"
);
assert!(
body.contains("class=\"folder-nav-toggle\""),
"the pull-tab toggle button should be in the markup"
body.contains("<details class=\"folder-picker\""),
"the folder nav should be a native disclosure"
);
assert!(
body.contains("toggleFolderNav()"),
"the toggle button should call toggleFolderNav()"
body.contains("class=\"folder-picker-summary\""),
"the disclosure should have a one-row summary"
);
assert!(
body.contains("aria-controls=\"folder-nav-list\""),
"the toggle should reference the folder nav list via aria-controls"
body.contains("id=\"folder-nav-list\""),
"the existing folder list should be the dropdown content"
);
assert!(
!body.contains("class=\"folder-nav-toggle\""),
"the old mobile pull-tab should be gone"
);
let summary = folder_picker_summary_region(&body);
assert!(
summary.contains("All Notes"),
"the summary should name the current folder"
);
assert!(
summary.contains("nav-count"),
"the summary should carry the current count"
);
}
/// The View menu has a Hide/Show Folder Nav toggle that shares the same state
/// as the pull-tab button.
#[tokio::test]
async fn folder_picker_names_the_active_folder() {
let f = Fixture::provisioned("folder-picker-active");
f.post_authed("/folders", "name=Alpha").await;
f.post_authed("/folders", "name=Beta").await;
let (status, body) = f.get_authed("/?folder=Alpha").await;
assert_eq!(status, StatusCode::OK);
let summary = folder_picker_summary_region(&body);
assert!(
summary.contains(">Alpha<"),
"the summary should name the open folder"
);
assert!(
!summary.contains("All Notes"),
"the folder label should replace the All Notes label"
);
}
/// The View menu has a Hide/Show Folder Nav toggle. The old mobile pull-tab
/// was removed with the one-row picker, so this is now the collapse control.
#[tokio::test]
async fn view_menu_has_folder_nav_toggle() {
let f = Fixture::provisioned("view-menu-folder-nav");
@ -1581,19 +1641,17 @@ async fn toolbar_actions_are_a_noscript_fallback() {
}
}
/// On mobile, the folder nav and note list scroll independently within their
/// own bounded areas. The sidebar itself does not scroll, and the pull-tab
/// toggle stays visible above the scrolling folder list.
/// On mobile the folder picker is a single row, so only the note list needs an
/// independent scroll area. The dropdown overlays the note list and scrolls
/// itself, and the old pull-tab row is gone.
#[tokio::test]
async fn mobile_folder_nav_scrolls_independently() {
let f = Fixture::provisioned("mobile-independent-scroll");
async fn mobile_folder_picker_is_a_single_row() {
let f = Fixture::provisioned("mobile-folder-picker");
f.post_authed("/folders", "name=Alpha").await;
let (status, body) = f.get_authed("/").await;
assert_eq!(status, StatusCode::OK);
// The mobile CSS must make the sidebar non-scrollable and give the
// folder nav and note list their own scroll areas.
let mobile_css_start = body
.find("@media (max-width: 600px)")
.expect("mobile media query should exist");
@ -1603,17 +1661,21 @@ async fn mobile_folder_nav_scrolls_independently() {
mobile_css.contains(".sidebar") && mobile_css.contains("overflow: hidden"),
"mobile sidebar should not scroll"
);
assert!(
mobile_css.contains(".folder-nav") && mobile_css.contains("overflow-y: auto"),
"folder nav should scroll independently"
);
assert!(
mobile_css.contains(".note-list") && mobile_css.contains("overflow-y: auto"),
"note list should scroll independently"
);
assert!(
mobile_css.contains("max-height: 40%"),
"folder nav container should have a max height"
mobile_css.contains(".folder-picker-summary") && mobile_css.contains("min-height: 44px"),
"the picker summary should be a 44px touch target"
);
assert!(
mobile_css.contains(".folder-nav") && mobile_css.contains("max-height: 50dvh"),
"the dropdown should cap its own height"
);
assert!(
!mobile_css.contains(".folder-nav-toggle"),
"the pull-tab styles should be gone"
);
}
@ -1636,6 +1698,18 @@ fn folder_nav_region(body: &str) -> &str {
&rest[..end]
}
/// The folder picker summary, and nothing else.
fn folder_picker_summary_region(body: &str) -> &str {
let start = body
.find("class=\"folder-picker-summary\"")
.expect("the folder picker summary should be present");
let rest = &body[start..];
let end = rest
.find("</summary>")
.expect("the folder picker summary should close");
&rest[..end]
}
/// Counts the badges inside one nav item's link.
///
/// Returns `None` when the label is not in the nav at all, so a test can tell
@ -2762,6 +2836,18 @@ async fn hiding_folder_nav_refreshes_sidebar_to_all_notes() {
!refresh_fn.contains("location.reload"),
"refreshSidebarToAllNotes should not reload the page"
);
assert!(
refresh_fn.contains(".folder-picker-summary"),
"refresh should update the picker summary"
);
assert!(
refresh_fn.contains(".file-menu-dropdown form[action$=\"/notes\"] input[name=\"folder\"]"),
"refresh should update the File menu New Note form"
);
assert!(
!refresh_fn.contains(".toolbar input[name=\"folder\"]"),
"the stale toolbar folder selector should be gone"
);
}
/// GET a path and return its status and body.