Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ All notable changes to Pasteup are recorded here. The format follows
those drives, and the `__MACOSX` folder left by unpacking a zip made on a
Mac, are no longer offered as bundles. Covers no longer take images from
them, nor from a `---Created---` folder inside the bundle.
- After a scan or making images, keyboard focus returns to the button that
started it, instead of falling back to the top of the page.

## [0.1.0] - 2026-10-16

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ Behavior defaults:
- Images per page: `12` (fixed 4x3).
- Export naming: `page_001`, `page_002`, ...
- Export conflict handling: never overwrite existing `page_###`; continue at next index.
- Upscaled images keep their image's name, in `Upscaled/PNG` and `Upscaled/JPG`,
so upscaling again replaces the files the last run made.

---

Expand Down Expand Up @@ -194,6 +196,10 @@ Validates a folder and scans for supported image files.
- `image_count` (int): number of supported files found.
- `sample_files` (list[str]): up to 5 sorted sample filenames.
- `estimated_pages` (int): `image_count // 12` (whole pages only).
- `available_subfolders` (list): when the folder has no images of its own, the
folders inside it, each with `display_name` and `full_path`, for picking one
bundle or listing many. Hidden folders, `__MACOSX` and `---Created---` are
left out. Empty when the folder has images.
- `message` (str): summary or error detail.

### `POST /api/jobs/browse-folder`
Expand Down
12 changes: 10 additions & 2 deletions src/pasteup/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,24 @@ function describeErrorResponse(response, data) {
}

// One request-backed action at a time: while it runs, the action buttons are
// disabled, so a second click cannot start a duplicate export.
// disabled, so a second click cannot start a duplicate export. Disabling the
// focused button drops keyboard focus to the page, so afterwards it goes back
// to that button, rather than leaving a keyboard user at the top of the page.
async function runExclusive(action) {
if (generationState.busy) {
return;
}

const startedFrom = document.activeElement;
setBusy(true);
try {
await action();
} finally {
setBusy(false);
// Unless focus has been put somewhere else in the meantime.
if (document.activeElement === document.body && startedFrom !== document.body && startedFrom?.isConnected) {
startedFrom.focus();
}
}
}

Expand Down Expand Up @@ -1867,7 +1874,8 @@ async function useBrowsedFolder() {
resetScanReadyState();
resetCoverCollageIncludeList();
await runExclusive(scanFolderAndCheckBundles);
// The scan disables Browse, which drops keyboard focus back to the page.
// Where closing the dialog didn't hand focus back to Browse, there was no
// button for runExclusive to return it to.
if (document.activeElement === document.body) {
browseFolderButton?.focus();
}
Expand Down
10 changes: 10 additions & 0 deletions tests/test_ui_generation_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ def test_app_js_reads_result_details_from_fields_not_prose() -> None:
assert 'result.backgrounds_cleaned > 0' in script


def test_app_js_returns_focus_to_the_button_that_started_an_action() -> None:
"""Disabling the focused button used to leave keyboard users at the top of the page."""
script = APP_JS.read_text()
run_exclusive = script[script.index("async function runExclusive(action) {") :]
run_exclusive = run_exclusive[: run_exclusive.index("\n}\n")]

assert "const startedFrom = document.activeElement;" in run_exclusive
assert "startedFrom.focus();" in run_exclusive


def test_app_js_routes_every_request_through_the_error_aware_helper() -> None:
"""A failed request used to render as "Finished — Done."."""
script = APP_JS.read_text()
Expand Down
Loading