Skip to content

perf: a menu's step and a press draw only the controls they change - #26

Merged
adammharris merged 1 commit into
mainfrom
claude/diaryx-menu-performance-mobile-8w5lmm
Nov 17, 2026
Merged

adammharris merged 1 commit into
mainfrom
claude/diaryx-menu-performance-mobile-8w5lmm

Conversation

@adammharris

Copy link
Copy Markdown
Member

MenuButton read the whole layer to know whether its menu was open, and Modal and PhotoViewer read it for the page's size: every step of the pointer over an open menu, and every toast, drew each of them again. Each focusable control read which control has the keys (Unit::focused), so a press anywhere drew every control on the page.

All four are memos now (use_memo), which tell only the controls whose answer changed:

  • Focus holds a Memo<bool> of whether it has the keys; is_focused and ring read it.
  • MenuButton's aria-expanded reads a memo of menu_owner() == Some(id).
  • Modal and PhotoViewer read a memo of viewport.

Found while timing Diaryx's entry menus on a library of 2,000 pages, where a search draws a "…" for every hit (diaryx-org/diaryx, same branch).

Checks

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo clippy -p unit-gallery --target wasm32-unknown-unknown --no-default-features --features web -- -D warnings
  • cargo test --workspace: all pass, including the Blitz and audit suites
  • RUSTDOCFLAGS='-D warnings' cargo doc -p unit --no-deps

Run with cargo; corgi isn't installed in this environment.


Generated by Claude Code

`MenuButton` read the whole layer to know whether its menu was open, and
`Modal` and `PhotoViewer` read it for the page's size: every step of the
pointer over an open menu, and every toast, drew each of them again. Each
focusable control read which control has the keys, so a press anywhere
drew every control on the page. All four are memos now, which tell only
the controls whose answer changed.

Found while timing Diaryx's entry menus on a library of 2,000 pages, where
a search draws a "…" for every hit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P3EBi1gz7evG9fSSg22tcL
@adammharris
adammharris merged commit a6d9757 into main Nov 17, 2026
7 checks passed
@adammharris
adammharris deleted the claude/diaryx-menu-performance-mobile-8w5lmm branch November 17, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant