fix(workflow-filter): field should appear on first load#50
Merged
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 synchronousquerySelectorthat 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— newwaitForElement<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.ts—initis now async, useswaitForElementinstead of synchronousfindNavList(). dev-onlyconsole.warnwhen 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— addedhappy-domdev dep for DOM test environment.Testing Notes
pnpm test— 92 tests passingpnpm lint— cleanpnpm check— clean