Skip to content

refactor(ui): move multiline :on* handlers in examples into named methods - #424

Merged
JuroOravec merged 1 commit into
mainfrom
ui/named-handlers
Oct 25, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
ui/named-handlers

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Part 3 of #141. The Citry UI snippets and quality scenarios passed 41 block-bodied arrow functions inline as :on* callbacks, many of them spanning several lines inside a tag. This PR moves each one into the example's js methods block, under a name that says what it does, and the tag now binds it by name.

What stays the same

  • Behaviour. Each method keeps the handler's arguments, side effects, and their order, and writes data through this.. The old arrows returned nothing, and the components ignore a callback's return value. No handler's logic changed.
  • Short handlers. A handler that is one short expression, including one wrapped after its =>, stays inline. Issue Clean up remaining Citry UI template formatting #141 only covers handlers whose line ends in a { block.

Proof

Every converted handler is driven by an e2e test. For the handlers that had no test of their effect, this PR adds 24 new e2e tests. Each was written against the old code first, then run against the new code.

  • New test files:
    • cdialog/tests/e2e/test_cdialog_open_change_callbacks_e2e.py
    • cdisclosure/.../test_cdisclosure_open_change_callbacks_e2e.py
    • cpopover/.../test_cpopover_open_change_callbacks_e2e.py
    • ctooltip/.../test_ctooltip_open_change_callbacks_e2e.py
    • cimage/.../test_cimage_status_callbacks_e2e.py
    • ctabs/.../test_ctabs_examples_e2e.py
    • ctags_input/.../test_ctags_input_examples_e2e.py
  • Existing e2e files with new tests added: alert dialog, command palette, context menu, and data grid.
  • The tests catch real breakage. We deleted data writes from several methods, and the matching tests failed.
  • Results: the e2e results are identical before and after the change, run one file at a time. The Citry UI unit suite passes (3,261 tests). Ruff is clean.
  • Pre-existing failures: the two Tabs tailwind e2e cases fail before and after, because quality/css/.generated/tailwind.css is not built in that checkout.
  • Not run locally: the docs e2e tests that build the whole site, because the machine was overloaded. The new family tests drive the same snippets more directly. The cargo phases and the full e2e suite are left to PR CI.

Each of the three batches had its own independent reviewer and a prose pass. None found a change in behaviour.

Left out on purpose

  • Callbacks written inside v-bind="{ onAction: (...) => { ... } }" objects in some CContextMenu, CMenu and CSplitButton snippets. These are not :on* attributes. They could be a small follow-up.
  • Inline handler examples in api.md pages (CAlertDialog, CDialog, CPopover, CTabs, CTooltip). They are short page examples, not copies of the snippets.

Found along the way

🤖 Generated with Claude Code

…hods

Part 3 of #141. The Citry UI snippets and quality scenarios passed 41
block-bodied arrow functions inline as `:on*` callbacks, many spanning
several lines inside a tag. Each now lives in the example's `js`
`methods` block under a name that says what it does, and the tag binds
it by name, so the template reads as markup and the logic reads as
JavaScript.

The methods keep each handler's arguments, side effects, and order, and
write data through `this.`. The old arrows returned nothing, and the
components ignore what a callback returns. Short single-expression
handlers stay inline. No handler's logic changed.

Every converted handler is proven by a browser test. 24 new e2e tests
cover the handlers that had none, each written against the old code
first and then run against the new. Tests that assert a callback's
effect cover CAlertDialog, CCommandPalette, CContextMenu, CDataGrid,
CDialog, CDisclosure, CDrawer, CImage, CPopover, CScrollArea, CTabs,
CTagsInput, and CTooltip.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit 00e447c into main Oct 25, 2026
22 of 26 checks passed
@JuroOravec
JuroOravec deleted the ui/named-handlers branch October 25, 2026 16:23
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