Skip to content

Commit 1f91f00

Browse files
committed
fix(appellate): Tweaks ACMSPageHandler to handle firefox load
1 parent 1cd7bc8 commit 1f91f00

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Features:
99

1010
Changes:
1111
- Namespace RECAP button CSS to avoid Bootstrap overrides
12+
- Updates ACMS page observer to handle Firefox page load timing
1213

1314
Fixes:
1415
- None yet

src/appellate/appellate.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
let acmsPageObserver = null;
2+
13
// Abstraction of scripts related to Appellate PACER to make them modular and
24
// testable.
35
let AppellateDelegate = function (tabId, court, url, path, links) {
@@ -74,21 +76,24 @@ AppellateDelegate.prototype.ACMSPageHandler = function () {
7476

7577
// If ACMS has already rendered the main content container (indexContent),
7678
// we can immediately initialize the docket handler without waiting for
77-
// HTMX updates. This prevents unnecessary observer creation and avoids
78-
// double-handling when navigating back/forward.
79+
// HTMX updates. This handles cases where the page loads fully before
80+
// the extension runs or when navigating back/forward.
7981
if (
8082
document.getElementById('indexContent') ||
8183
document.getElementById('fullDocketContent')
8284
) {
8385
this.handleAcmsDocket();
84-
} else {
85-
// Otherwise, the page is still loading partial content via HTMX.
86-
// Set up a MutationObserver on <body> to detect when ACMS injects
87-
// the relevant sections.
88-
const body = document.querySelector('body');
89-
const observer = new MutationObserver(pageObserver);
90-
observer.observe(body, { subtree: true, childList: true });
9186
}
87+
88+
if (acmsPageObserver) return;
89+
90+
// Always set up the observer to watch for HTMX updates, even if content
91+
// is already present. HTMX can trigger partial page updates at any time,
92+
// and we need to respond to those changes in both Chrome (node-by-node
93+
// loading) and Firefox (full page already loaded).
94+
const body = document.querySelector('body');
95+
acmsPageObserver = new MutationObserver(pageObserver.bind(this));
96+
acmsPageObserver.observe(body, { subtree: true, childList: true });
9297
};
9398

9499
// Identify and handle pages from Appellate courts.

0 commit comments

Comments
 (0)