Skip to content

Fix the analysis re-run button silently doing nothing - #1063

Closed
skerbis wants to merge 1 commit into
fix/analysis-toolbar-hardeningfrom
fix/analysis-rerun-button-click-handler
Closed

Fix the analysis re-run button silently doing nothing#1063
skerbis wants to merge 1 commit into
fix/analysis-toolbar-hardeningfrom
fix/analysis-rerun-button-click-handler

Conversation

@skerbis

@skerbis skerbis commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

Stacked on #1062 (toolbar hardening) — please review/merge that one first.

The button's click handler was only ever bound from a DOMContentLoaded listener. A script added via rex_view::addJsFile() can finish loading/executing after that event already fired (common on a backend page with many other scripts), in which case the listener never runs at all - no handler ever gets bound, and the link's href="#" just does nothing on click, which is exactly what was being observed.

Fixed the same way this project's own ai-chat-warm-cache.js already does it: try a jQuery rex:ready listener (also covers REDAXO's own AJAX-driven content swaps), fall back to DOMContentLoaded, and call init() unconditionally as well to cover the case where the DOM is already ready by the time this script runs. init() now guards against running its setup more than once per page load (a dataset flag on the app root), since it can legitimately fire from multiple triggers now.

Also moved the script registration from pages/analysis.php into boot.php, gated to this subpage specifically - matches this addon's own existing confetti.min.js pattern instead of introducing a second, different way of loading a JS file for the same page.

Test plan

  • Verified the click handler binds and fires correctly regardless of load timing (tested the "script loads after DOMContentLoaded" race specifically).
  • php -l + PHPStan on the changed files: 0 findings.

🤖 Generated with Claude Code

The button's click handler was only ever bound from a
DOMContentLoaded listener. A script added via rex_view::addJsFile()
can finish loading/executing after that event already fired (common
on a backend page with many other scripts), in which case the
listener never runs at all - no handler ever gets bound, and the
link's href="#" just does nothing on click, which is exactly what was
being seen.

Fixed the same way this project's own ai-chat-warm-cache.js already
does it: try a jQuery "rex:ready" listener (also covers REDAXO's own
AJAX-driven content swaps), fall back to DOMContentLoaded, and call
init() unconditionally as well to cover the case where the DOM is
already ready by the time this script runs. init() now guards against
running its setup more than once per page load (a dataset flag on the
app root), since it can legitimately fire from multiple triggers now.

Also moved the script registration from pages/analysis.php into
boot.php, gated to this subpage specifically - matches this addon's
own existing confetti.min.js pattern instead of introducing a second,
different way of loading a JS file for the same page.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@skerbis

skerbis commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Closing as part of flattening the stack into independent PRs — this and #1062/#1064 are being combined into one PR ("Harden, fix and animate the analysis re-run trigger"), based on #1067 instead of chained serially. Will link the replacement here once opened.

@skerbis

skerbis commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Combined into #1068.

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