# Split the hooks out of app.js closes #554 #626

Merged
simon merged 12 commits from issue/mitgliederverwaltung-554 into main 2026-10-27 16:41:48 +01:00
Owner

closes #554

Description of the implemented changes

The changes were:

  • Bugfixing
  • New Feature
  • Breaking Change
  • Refactoring

assets/js/app.js held every LiveView hook and several page-specific listeners; it is now wiring only. Hooks with one owner live as colocated hooks next to the component or LiveView that uses them, hooks shared by several modules live in assets/js/hooks/, and a test fails when a phx-hook name resolves to no registered hook. While moving the clipboard hook, copying email addresses turned out to fail silently in Safari (and in Firefox after a slow server reply), because the clipboard write started only after the server round trip; it now starts in the click and the success toast waits for the browser's confirmation.

What has been changed?

  • Fail when a phx-hook name resolves to no registered hook
  • Drop the set-input-value listener no server event triggers
  • Give hooks that several modules share their own files
  • Colocate single-owner hooks with the component or LiveView that uses them
  • Handle the view settings and scroll reset pushes in an overview hook
  • Copy email addresses in Safari and confirm only a copy that happened
  • Copy the join page URL in the click and confirm only a successful copy
  • Keep hook definitions and page listeners out of app.js
  • Describe where hooks live and how they copy to the clipboard
  • List the events, server pushes and URL parameters the overview handles
  • Drop overview tests the bulk actions component tests already cover

Definition of Done

Code Quality

  • No new technical depths
  • Linting passed
  • Documentation is added were needed

Accessibility

  • New elements are properly defined with html-tags
  • Colour contrast follows WCAG criteria
  • Aria labels are added when needed
  • Everything is accessible by keyboard
  • Tab-Order is comprehensible
  • All interactive elements have a visible focus

Testing

  • Tests for new code are written
  • All tests pass
  • axe-core dev tools show no critical or major issues

Additional Notes

Oversized commits: "Colocate single-owner hooks …" (8 files, +406 −390, hook code moved out of app.js) and "Copy email addresses in Safari …" (14 files, +500 −178, about half of it tests).
The copy flow was checked in Firefox 150, Chromium 148 and WebKit 26.4 (Playwright) and by hand in Safari; LiveViewTest does not run JS, so the JS bundle build (just mix assets.build) is not part of just ci-dev yet — a follow-up adds it to just lint.

--- closes #554 ## Description of the implemented changes The changes were: - [x] Bugfixing - [ ] New Feature - [ ] Breaking Change - [x] Refactoring `assets/js/app.js` held every LiveView hook and several page-specific listeners; it is now wiring only. Hooks with one owner live as colocated hooks next to the component or LiveView that uses them, hooks shared by several modules live in `assets/js/hooks/`, and a test fails when a `phx-hook` name resolves to no registered hook. While moving the clipboard hook, copying email addresses turned out to fail silently in Safari (and in Firefox after a slow server reply), because the clipboard write started only after the server round trip; it now starts in the click and the success toast waits for the browser's confirmation. ## What has been changed? - Fail when a phx-hook name resolves to no registered hook - Drop the set-input-value listener no server event triggers - Give hooks that several modules share their own files - Colocate single-owner hooks with the component or LiveView that uses them - Handle the view settings and scroll reset pushes in an overview hook - Copy email addresses in Safari and confirm only a copy that happened - Copy the join page URL in the click and confirm only a successful copy - Keep hook definitions and page listeners out of app.js - Describe where hooks live and how they copy to the clipboard - List the events, server pushes and URL parameters the overview handles - Drop overview tests the bulk actions component tests already cover ## Definition of Done ### Code Quality - [ ] No new technical depths - [x] Linting passed - [x] Documentation is added were needed ### Accessibility - [ ] New elements are properly defined with html-tags - [ ] Colour contrast follows WCAG criteria - [ ] Aria labels are added when needed - [ ] Everything is accessible by keyboard - [ ] Tab-Order is comprehensible - [ ] All interactive elements have a visible focus ### Testing - [x] Tests for new code are written - [x] All tests pass - [ ] axe-core dev tools show no critical or major issues ## Additional Notes Oversized commits: "Colocate single-owner hooks …" (8 files, +406 −390, hook code moved out of app.js) and "Copy email addresses in Safari …" (14 files, +500 −178, about half of it tests). The copy flow was checked in Firefox 150, Chromium 148 and WebKit 26.4 (Playwright) and by hand in Safari; LiveViewTest does not run JS, so the JS bundle build (`just mix assets.build`) is not part of `just ci-dev` yet — a follow-up adds it to `just lint`.
Safari refuses a clipboard write that starts after a server round trip, and
Firefox one that starts about five seconds after the click. The hook now
starts a ClipboardItem write inside the click whose content is the promise of
the server's reply, and the success toast waits for the browser's confirmation.
docs(changelog): record the clipboard fixes for email addresses and the join link under Unreleased
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing
f5e34d6276
simon merged commit 57ceac2f94 into main 2026-10-27 16:41:48 +01:00
simon deleted branch issue/mitgliederverwaltung-554 2026-10-27 16:41:48 +01:00
Sign in to join this conversation.
No description provided.