Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Features:

Changes:
- Namespace RECAP button CSS to avoid Bootstrap overrides
- Updates ACMS page observer to handle Firefox page load timing ([#422](https://github.com/freelawproject/recap-chrome/pull/422))


Fixes:
- None yet
Expand Down
23 changes: 14 additions & 9 deletions src/appellate/appellate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
let acmsPageObserver = null;

// Abstraction of scripts related to Appellate PACER to make them modular and
// testable.
let AppellateDelegate = function (tabId, court, url, path, links) {
Expand Down Expand Up @@ -74,21 +76,24 @@ AppellateDelegate.prototype.ACMSPageHandler = function () {

// If ACMS has already rendered the main content container (indexContent),
// we can immediately initialize the docket handler without waiting for
// HTMX updates. This prevents unnecessary observer creation and avoids
// double-handling when navigating back/forward.
// HTMX updates. This handles cases where the page loads fully before
// the extension runs or when navigating back/forward.
if (
document.getElementById('indexContent') ||
document.getElementById('fullDocketContent')
) {
this.handleAcmsDocket();
} else {
// Otherwise, the page is still loading partial content via HTMX.
// Set up a MutationObserver on <body> to detect when ACMS injects
// the relevant sections.
const body = document.querySelector('body');
const observer = new MutationObserver(pageObserver);
observer.observe(body, { subtree: true, childList: true });
}

if (acmsPageObserver) return;

// Always set up the observer to watch for HTMX updates, even if content
// is already present. HTMX can trigger partial page updates at any time,
// and we need to respond to those changes in both Chrome (node-by-node
// loading) and Firefox (full page already loaded).
const body = document.querySelector('body');
acmsPageObserver = new MutationObserver(pageObserver.bind(this));
acmsPageObserver.observe(body, { subtree: true, childList: true });
};

// Identify and handle pages from Appellate courts.
Expand Down