Skip to content

fix(workflow-filter): field should appear on first load#50

Merged
cheefbird merged 5 commits into
mainfrom
fix/filter-loading-bug
Apr 1, 2026
Merged

fix(workflow-filter): field should appear on first load#50
cheefbird merged 5 commits into
mainfrom
fix/filter-loading-bug

Conversation

@cheefbird
Copy link
Copy Markdown
Owner

Context

workflow-filter wasn't showing up on first navigation to the actions page in firefox. required a manual refresh to appear.

root cause: findNavList() ran a synchronous querySelector that returned null because WXT's location change event fires before github's react finishes rendering the sidebar.

note: chrome was unaffected because it uses the Navigation API (event-driven) while firefox falls back to polling, hitting a different timing window.

Closes: #49

Changes Made

src/lib/dom.ts — new waitForElement<T>() utility. MutationObserver-based, resolves when selector appears in DOM. integrates with AbortSignal for cleanup, returns null on abort. generic type param for typed returns.

src/lib/dom.test.ts — 8 tests covering fast-path, async detection, timeout, abort, pre-aborted signal, nested elements, observer cleanup verification, and element+abort race condition. uses happy-dom environment.

src/entrypoints/grody.content/features/workflow-filter/index.tsinit is now async, uses waitForElement instead of synchronous findNavList(). dev-only console.warn when nav element isn't found (tree-shaken in prod). showMore/totalPages checks remain synchronous since they're children of the nav element that was just resolved.

package.json — added happy-dom dev dep for DOM test environment.

Testing Notes

  • load extension in firefox, navigate to a repo's actions page via link (not direct URL) — filter bar should appear without refresh
  • verify chrome still works as before (no regression)
  • verify filter bar still doesn't render on repos with <= 1 page of workflows
  • pnpm test — 92 tests passing
  • pnpm lint — clean
  • pnpm check — clean

- MutationObserver-based helper that waits for a selector to show up in the DOM
- integrates with AbortSignal for cleanup, returns null on abort
- supports generic type param for typed returns
covers fast-path resolution, async MutationObserver detection, timeout expiry,
abort signal handling, pre-aborted signals, and nested element discovery.
uses happy-dom environment.
…firefox

replaces synchronous findNavList() with waitForElement so the filter bar mounts
even when github's sidebar hasn't rendered yet. fixes the race condition where
firefox SPA navigation fires before react hydrates the actions page nav.
…esting

- dev-mode console.warn when sidebar nav isn't found (tree-shaken in prod)
- tests for observer cleanup after resolution and element+abort race condition
@cheefbird cheefbird self-assigned this Apr 1, 2026
@cheefbird cheefbird changed the title Fix/filter loading bug fix(workflow-filter): field should appear on first load Apr 1, 2026
@cheefbird cheefbird merged commit a69dc54 into main Apr 1, 2026
4 checks passed
@cheefbird cheefbird deleted the fix/filter-loading-bug branch April 1, 2026 03:50
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.

Filter/search bar doesn't load unless you manually refresh

1 participant