Skip to content

Detect React navigation and re-apply features#9830

Merged
fregante merged 4 commits into
mainfrom
enable-react-navigation
Jul 15, 2026
Merged

Detect React navigation and re-apply features#9830
fregante merged 4 commits into
mainfrom
enable-react-navigation

Conversation

@fregante

Copy link
Copy Markdown
Member

I want to test-drive just this listener, we can then address any issues separately. React navigation is long overdue and this should cover most of the functionality.

I think we don't really need to unload features, with few exceptions, it's mostly a performance optimization. They're still unloaded when a regular pjax navigation happens. Our delegate and observe calls are natively deduplicated already, so it won't actually break anything if init is called twice in a row.

Svelte components will eventually enable us to have features that auto-update.

@fregante fregante left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last workaround that mentions is #6554. This might have to be fixed via svelte instead.

// Update on hover because the URL may change without a DOM refresh
// https://github.com/refined-github/refined-github/issues/6554
// Inlined listener because `mouseenter` is too heavy for `delegate`
onMouseEnter={updateUrl}

include: [
pageDetect.isConversation,
// Workaround for https://github.com/refined-github/refined-github/issues/6554
pageDetect.isRepoIssueOrPRList,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this PR after I verified these

function init(signal: AbortSignal): void {
// TODO: Revert #9086 after https://github.com/refined-github/refined-github/issues/6554
// Exclude reference to a comment on the same page
observe('.markdown-body:not(section[aria-label="Events"] *) a.issue-link:not([href*="#"])', underlineSelfReference, {

@fregante fregante Jul 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code wasn't substantially better, so it's ok to leave this workaround and drop the comment.

@fregante fregante left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All issues verified and fixed. Going ahead

// Do not move to `includes` until React AJAX issues are resolved:
// https://github.com/refined-github/refined-github/pull/7524#issuecomment-2211692096
// https://github.com/refined-github/refined-github/issues/6554
if (new URLSearchParams(location.search).get('type') !== 'repositories') {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually where "leave the listeners active" is a problem: the selector was too broad, so #7520 was resurfaced:

Image


function initSearch(signal: AbortSignal): void {
observe('.search-title a', addSearchConversationLinks, {signal});
observe('a[class^="Repositories-module__stargazersLink"]', addSearchConversationLinks, {signal});

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the fix was to make the selector more specific, which actually simplifies the DOM traversing in the add callback

Image

@fregante fregante added the bug label Jul 15, 2026
@fregante fregante changed the title Listen to React navigation Detect React navigation and re-apply features Jul 15, 2026
@fregante
fregante merged commit 37ace9e into main Jul 15, 2026
19 checks passed
@fregante
fregante deleted the enable-react-navigation branch July 15, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant