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
5 changes: 5 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2025-10-29 - Explicit ARIA Labels for Interactive Controls and Form Inputs

**Learning:** In server-rendered HTML templates (`templates.rs`) and dynamic TS panels (`search-panel.ts`), standalone inputs and buttons (such as search replace buttons, toggle checkboxes, and session inputs) frequently lack explicit `aria-label` attributes even when visually grouped.
**Action:** Always verify that every input element and icon/action button has an explicit `aria-label` or `aria-labelledby` attribute to ensure complete screen reader accessibility across both server templates and client DOM components.

## 2026-10-30 - Server-Rendered Template Action Buttons Missing ARIA Labels

**Learning:** Server-rendered HTML templates generating compact/action buttons (like `save`, `rename`, `copy`, or `clear`) often include visual text labels or `title` tooltips but lack explicit `aria-label` attributes. Screen reader users navigating by interactive controls or relying on accessible names need `aria-label` attributes to ensure consistent screen reader announcement across browser environments.
Expand Down
4 changes: 2 additions & 2 deletions pkgs/id/src/commands/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ use crate::discovery::PeerAnnouncement;
use crate::local::LocalNode;
use crate::meta_client::{MetaRequester, expect_ok, read_capped_response, request_over};
use crate::{
CLIENT_KEY_FILE, FindMatch, META_ALPN, MatchKind, MetaRequest, MetaResponse, StoreType,
export_blob, is_node_id, load_or_create_keypair, open_store,
CLIENT_KEY_FILE, FindMatch, META_ALPN, MetaRequest, MetaResponse, StoreType, export_blob,
is_node_id, load_or_create_keypair, open_store,
};

/// The current Unix time in seconds, or `0` if the clock is before the epoch.
Expand Down
2 changes: 1 addition & 1 deletion pkgs/id/src/web/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub fn render_file_list(page: &FileListPage) -> String {
value=\"{}\" />",
search_value
);
html.push_str("<label class=\"flex items-center gap-1 text-xs whitespace-nowrap cursor-pointer\"><input type=\"checkbox\" id=\"show-auto\" class=\"checkbox checkbox-xs\" /> show auto/archive</label>");
html.push_str("<label class=\"flex items-center gap-1 text-xs whitespace-nowrap cursor-pointer\"><input type=\"checkbox\" id=\"show-auto\" class=\"checkbox checkbox-xs\" aria-label=\"Show auto and archive files\" /> show auto/archive</label>");
let _ = write!(
html,
"<label class=\"flex items-center gap-1 text-xs whitespace-nowrap cursor-pointer\"><input type=\"checkbox\" id=\"show-deleted\" name=\"show_deleted\" value=\"true\" class=\"checkbox checkbox-xs\"{} /> show deleted</label>",
Expand Down
2 changes: 1 addition & 1 deletion pkgs/id/src/world_doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn check_toolchain(inputs: &DoctorInputs) -> Finding {
};
// A configured binary must exist. A bare name resolves through PATH.
let exists = if roc_bin.contains('/') {
std::path::Path::new(roc_bin).is_file()
Path::new(roc_bin).is_file()
} else {
std::env::split_paths(&std::env::var_os("PATH").unwrap_or_default())
.map(|dir| dir.join(roc_bin))
Expand Down
2 changes: 1 addition & 1 deletion pkgs/id/src/world_session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mod tests;
mod types;

pub(crate) use types::{
CAPS_CEILING_NOTICE, ClientFrame, CompileFile, MAX_ADMIN_TOKEN_BYTES, MAX_CAPABILITY_BYTES,
CAPS_CEILING_NOTICE, ClientFrame, MAX_ADMIN_TOKEN_BYTES, MAX_CAPABILITY_BYTES,
MAX_CONCURRENT_MODULE_UPLOADS, ServerFrame, invite_bounds,
};
pub use types::{
Expand Down
4 changes: 2 additions & 2 deletions pkgs/id/src/world_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use std::path::{Path, PathBuf};
use anyhow::{Context, Result, bail, ensure};

use crate::world::{
JOURNAL_VERSION, JOURNAL_VERSION_EXECUTION_PROFILE, JournalEntry, WorldCore, WorldEventKind,
WorldHandle, WorldJournal, WorldLimits, WorldProgram, journal_version_required_by,
JOURNAL_VERSION, JournalEntry, WorldCore, WorldEventKind, WorldHandle, WorldJournal,
WorldLimits, WorldProgram, journal_version_required_by,
};
use crate::world_session::{WorldService, module_hash};

Expand Down
124 changes: 88 additions & 36 deletions pkgs/id/web/src/goto-line.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ import { createGotoLinePlugin, destroyGotoLineDialog } from "./goto-line";
function createStateWithGotoLine(docContent?: string): EditorState {
const plugin = createGotoLinePlugin();
const doc = docContent
? rawSchema.node("doc", null, [rawSchema.node("code_block", null, docContent ? [rawSchema.text(docContent)] : [])])
? rawSchema.node("doc", null, [
rawSchema.node(
"code_block",
null,
docContent ? [rawSchema.text(docContent)] : [],
),
])
: undefined;
return EditorState.create({
schema: rawSchema,
Expand All @@ -27,7 +33,10 @@ function createStateWithGotoLine(docContent?: string): EditorState {
}

/** Create an EditorView in a container div with the goto-line plugin. */
function createViewWithGotoLine(docContent?: string): { view: EditorView; container: HTMLElement } {
function createViewWithGotoLine(docContent?: string): {
view: EditorView;
container: HTMLElement;
} {
const container = document.createElement("div");
document.body.appendChild(container);
const state = createStateWithGotoLine(docContent);
Expand All @@ -44,7 +53,11 @@ function triggerGotoLine(view: EditorView): boolean {
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- handleKeyDown this context workaround
const handler = (plugin.props as any).handleKeyDown;
if (!handler) return false;
return handler.call(plugin, view, new KeyboardEvent("keydown", { key: "g", ctrlKey: true }));
return handler.call(
plugin,
view,
new KeyboardEvent("keydown", { key: "g", ctrlKey: true }),
);
}

// ── Tracked resources for cleanup ──────────────────────────────────
Expand Down Expand Up @@ -193,7 +206,9 @@ describe("go-to-line command", () => {

triggerGotoLine(view);

const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
expect(input).not.toBeNull();
// 3 lines in doc → placeholder should contain "3"
expect(input.placeholder).toContain("3");
Expand Down Expand Up @@ -226,9 +241,13 @@ describe("dialog input interaction", () => {
const dialog = container.querySelector(".goto-line-dialog") as HTMLElement;
expect(dialog).not.toBeNull();

const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
// Simulate pressing Escape on the input
input.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
input.dispatchEvent(
new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
);

expect(dialog.style.display).toBe("none");
});
Expand All @@ -241,10 +260,14 @@ describe("dialog input interaction", () => {
triggerGotoLine(view);

const dialog = container.querySelector(".goto-line-dialog") as HTMLElement;
const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
input.value = "1";

input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
input.dispatchEvent(
new KeyboardEvent("keydown", { key: "Enter", bubbles: true }),
);
expect(dialog.style.display).toBe("none");
});

Expand All @@ -255,13 +278,17 @@ describe("dialog input interaction", () => {

triggerGotoLine(view);

const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
input.value = "2";

// Before: cursor is at default position
const _posBefore = view.state.selection.from;

input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
input.dispatchEvent(
new KeyboardEvent("keydown", { key: "Enter", bubbles: true }),
);

// After: cursor should have moved (to line 2 start)
// In rawSchema: doc > code_block > text "first\nsecond\nthird"
Expand All @@ -279,25 +306,36 @@ describe("dialog input interaction", () => {
["2.9", "fractional"],
["999", "out of range"],
["", "empty"],
])("Enter with %s (%s) does not move the cursor and keeps the dialog open", (value) => {
const { view, container } = createViewWithGotoLine("first\nsecond\nthird");
views.push(view);
containers.push(container);

triggerGotoLine(view);

const dialog = container.querySelector(".goto-line-dialog") as HTMLElement;
const input = container.querySelector(".goto-line-input") as HTMLInputElement;
input.value = value;
const posBefore = view.state.selection.from;

input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));

// #712: invalid input must not be silently reinterpreted (0 -> line 1,
// 2.9 -> line 2) or swallowed (999) — no move, dialog stays open.
expect(view.state.selection.from).toBe(posBefore);
expect(dialog.style.display).not.toBe("none");
});
])(
"Enter with %s (%s) does not move the cursor and keeps the dialog open",
(value) => {
const { view, container } = createViewWithGotoLine(
"first\nsecond\nthird",
);
views.push(view);
containers.push(container);

triggerGotoLine(view);

const dialog = container.querySelector(
".goto-line-dialog",
) as HTMLElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
input.value = value;
const posBefore = view.state.selection.from;

input.dispatchEvent(
new KeyboardEvent("keydown", { key: "Enter", bubbles: true }),
);

// #712: invalid input must not be silently reinterpreted (0 -> line 1,
// 2.9 -> line 2) or swallowed (999) — no move, dialog stays open.
expect(view.state.selection.from).toBe(posBefore);
expect(dialog.style.display).not.toBe("none");
},
);

it("Enter with line 1 moves cursor to the first line start", () => {
const { view, container } = createViewWithGotoLine("first\nsecond");
Expand All @@ -306,10 +344,14 @@ describe("dialog input interaction", () => {

triggerGotoLine(view);

const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
input.value = "1";

input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
input.dispatchEvent(
new KeyboardEvent("keydown", { key: "Enter", bubbles: true }),
);

// Line 1 starts at the code_block's content start: the block sits
// at pos 0, so its text starts at doc pos 1 (#745 doc-walk mapping).
Expand Down Expand Up @@ -343,9 +385,13 @@ describe("go-to-line across textblocks (#745)", () => {
}

function gotoLine(container: HTMLElement, value: string): void {
const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
input.value = value;
input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
input.dispatchEvent(
new KeyboardEvent("keydown", { key: "Enter", bubbles: true }),
);
}

it("rich doc of three paragraphs reports 3 lines and jumps to the second paragraph", () => {
Expand All @@ -357,7 +403,9 @@ describe("go-to-line across textblocks (#745)", () => {
const { view, container } = createViewFromDoc(richSchema, doc);

triggerGotoLine(view);
const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
// textContent is "alphabetagamma" (no separators) — the old count said 1.
expect(input.placeholder).toContain("3");
expect(input.max).toBe("3");
Expand All @@ -375,7 +423,9 @@ describe("go-to-line across textblocks (#745)", () => {
const { view, container } = createViewFromDoc(rawSchema, doc);

triggerGotoLine(view);
const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
expect(input.max).toBe("4");

gotoLine(container, "3");
Expand All @@ -397,7 +447,9 @@ describe("go-to-line across textblocks (#745)", () => {
const { view, container } = createViewFromDoc(richSchema, doc);

triggerGotoLine(view);
const input = container.querySelector(".goto-line-input") as HTMLInputElement;
const input = container.querySelector(
".goto-line-input",
) as HTMLInputElement;
expect(input.max).toBe("4");

gotoLine(container, "3");
Expand Down
4 changes: 3 additions & 1 deletion pkgs/id/web/src/goto-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ function openGotoLine(view: EditorView): void {
dialogInput?.select();
return;
}
const tr = activeView.state.tr.setSelection(TextSelection.create(activeView.state.doc, pos));
const tr = activeView.state.tr.setSelection(
TextSelection.create(activeView.state.doc, pos),
);
activeView.dispatch(tr);
activeView.focus();
// Scroll the cursor into view
Expand Down
37 changes: 26 additions & 11 deletions pkgs/id/web/src/search-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ function updateMatchCount(view: EditorView): void {
return;
}
const total = countMatches(view);
panelState.matchCountEl.textContent = total === 0 ? "No results" : `${total} match${total === 1 ? "" : "es"}`;
panelState.matchCountEl.textContent =
total === 0 ? "No results" : `${total} match${total === 1 ? "" : "es"}`;
}

/**
Expand All @@ -91,8 +92,10 @@ function searchStateChanged(prevState: EditorState, state: EditorState): boolean
function syncQuery(view: EditorView): void {
const searchText = panelState.searchInput?.value ?? "";
const replaceText = panelState.replaceInput?.value ?? "";
const caseCheckbox = panelState.panelEl?.querySelector<HTMLInputElement>("#search-case");
const regexCheckbox = panelState.panelEl?.querySelector<HTMLInputElement>("#search-regex");
const caseCheckbox =
panelState.panelEl?.querySelector<HTMLInputElement>("#search-case");
const regexCheckbox =
panelState.panelEl?.querySelector<HTMLInputElement>("#search-regex");

const query = new SearchQuery({
search: searchText,
Expand Down Expand Up @@ -129,8 +132,8 @@ function createPanel(container: HTMLElement): HTMLElement {
</div>
<div class="search-panel-row search-replace-row" id="search-replace-row" style="display:none">
<input type="text" id="replace-input" class="search-field" placeholder="Replace…" aria-label="Replace with" autocomplete="off" spellcheck="false" />
<button class="search-btn" id="replace-one" title="Replace">Replace</button>
<button class="search-btn" id="replace-all" title="Replace all" aria-label="Replace all">All</button>
<button class="search-btn" id="replace-one" title="Replace" aria-label="Replace match">Replace</button>
<button class="search-btn" id="replace-all" title="Replace all" aria-label="Replace all matches">All</button>
</div>
`;

Expand Down Expand Up @@ -205,8 +208,12 @@ function setupPanelEvents(): void {
});

// Case/regex toggles
panelEl.querySelector("#search-case")?.addEventListener("change", () => syncQuery(view));
panelEl.querySelector("#search-regex")?.addEventListener("change", () => syncQuery(view));
panelEl
.querySelector("#search-case")
?.addEventListener("change", () => syncQuery(view));
panelEl
.querySelector("#search-regex")
?.addEventListener("change", () => syncQuery(view));
}

/** Open find panel, optionally showing replace. */
Expand All @@ -219,16 +226,24 @@ function openPanel(view: EditorView, showReplace: boolean): void {
// is detached with the old container and its handlers still point at the
// destroyed view — and no production code calls destroySearchPanel() on
// teardown. Rebind instead of "opening" a detached node (#718).
if (panelState.panelEl && (panelState.view !== view || panelState.panelEl.parentElement !== container)) {
if (
panelState.panelEl &&
(panelState.view !== view || panelState.panelEl.parentElement !== container)
) {
destroySearchPanel();
}

if (!panelState.panelEl) {
panelState.panelEl = createPanel(container);
panelState.searchInput = panelState.panelEl.querySelector("#search-input");
panelState.replaceInput = panelState.panelEl.querySelector("#replace-input");
panelState.matchCountEl = panelState.panelEl.querySelector("#search-match-count");
panelState.replaceRow = panelState.panelEl.querySelector("#search-replace-row");
panelState.replaceInput =
panelState.panelEl.querySelector("#replace-input");
panelState.matchCountEl = panelState.panelEl.querySelector(
"#search-match-count",
);
panelState.replaceRow = panelState.panelEl.querySelector(
"#search-replace-row",
);
panelState.view = view;
setupPanelEvents();
}
Expand Down
Loading