fix(ui): reinit Alpine.js on OOB-swapped pagination controls after fi…#3206
fix(ui): reinit Alpine.js on OOB-swapped pagination controls after fi…#3206crivetimihai merged 4 commits intomainfrom
Conversation
|
Hi @crivetimihai thanks for reopening this! I've verified the code, everything looks good, intact and matching my original changes. Ready for review whenever you get the chance. Thanks! |
…ltering Closes #3039 Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
Signed-off-by: Oriol Morros Vilaseca <OM368@student.aru.ac.uk>
- Add {% set hx_swap = 'outerHTML' %} to teams_partial.html OOB
pagination controls, matching the pattern in all other partials
- Add 7 unit tests for Alpine.js reinitialization on OOB-swapped
pagination controls covering: uninitialized, already-initialized,
multiple controls, Alpine not loaded, initTree missing, no x-data
child, and toggle coexistence
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Change querySelectorAll selector from [id$="-pagination-controls"] to [id*="-pagination-controls"] so it also matches metrics top-performers IDs like "top-tools-pagination-controls-visible" which contain but don't end with "-pagination-controls". Add test for the metrics ID pattern. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
8a9096c to
ad683df
Compare
|
Rebased onto main (clean, no conflicts) and reviewed. Changes I made during review:
All 70 JS tests pass. |
crivetimihai
left a comment
There was a problem hiding this comment.
Reviewed and ready to merge. The fix correctly addresses both root causes (Alpine.js reinit race and wrong swap style). Added missing teams_partial fix, broadened selector to cover metrics pagination, and added comprehensive test coverage (70 tests passing).
🔗 Related Issue
Closes #3039
📝 Summary
When filtering/searching table items in the admin panel, pagination controls (page info text, navigation buttons) were not
rendering. This was caused by two issues:
the pagination controls div, but Alpine.js's MutationObserver doesn't reliably detect and initialize the new x-data
component. Added an htmx:afterSettle listener that explicitly calls Alpine.initTree() on uninitialized pagination controls.
elements, causing nested tables with duplicate IDs. Set hx_swap = 'outerHTML' across all partial templates and initial
renders in admin.html.
🏷️ Type of Change
🧪 Verification
┌────────────────┬───────────────┬────────┐
│ Check │ Command │ Status │
├────────────────┼───────────────┼────────┤
│ Lint suite │ make lint │ │
├────────────────┼───────────────┼────────┤
│ Unit tests │ make test │ │
├────────────────┼───────────────┼────────┤
│ Coverage ≥ 80% │ make coverage │ │
└────────────────┴───────────────┴────────┘
✅ Checklist
📓 Notes (optional)
Files changed:
(matching existing pattern in users_partial.html)
Screenshots:

