Skip to content

Fix feature loading on soft navigation between React-based pages - #8881

Closed
SunsetTechuila wants to merge 8 commits into
refined-github:mainfrom
SunsetTechuila:events
Closed

SunsetTechuila wants to merge 8 commits into
refined-github:mainfrom
SunsetTechuila:events

Conversation

@SunsetTechuila
SunsetTechuila marked this pull request as ready for review January 20, 2026 15:29
Comment thread package.json Resolved
@fregante

Copy link
Copy Markdown
Member
 one-event 4.4.0 published 🎉

@fregante fregante added the bug label Jan 22, 2026
Comment thread source/features/linkify-text.tsx Resolved
}
});
} while (await oneEvent(document, 'turbo:render'));
} while (await oneEvent(document, ['turbo:render', 'soft-nav:react-done']));

@SunsetTechuila SunsetTechuila Jan 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

unlike soft-nav:render, soft-nav:react-done is fired when user navigates the session history too

@SunsetTechuila SunsetTechuila changed the title Load features when navigating between React-based pages Fix features loading on soft navigation between React-based pages Jan 27, 2026
@SunsetTechuila SunsetTechuila changed the title Fix features loading on soft navigation between React-based pages Fix feature loading on soft navigation between React-based pages Jan 27, 2026
document.addEventListener('turbo:before-fetch-request', unloadAll); // Clicks
document.addEventListener('turbo:visit', unloadAll); // Back/forward button
document.addEventListener('soft-nav:progress-bar:start', unloadAll); // Soft navigation
document.addEventListener('soft-nav:start', unloadAll); // Soft navigation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a bit too early, but other events are fired too late

Comment on lines +131 to +132
document.addEventListener('soft-nav:start', unloadAll); // Soft navigation
addEventListener('popstate', unloadAll); // History navigation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you reckon that we can proceed without these two early events or do they cause too much trouble/noise in the console?

What does "firing too early" mean? Does the page break visually?

@SunsetTechuila SunsetTechuila Jan 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What does "firing too early" mean? Does the page break visually?

Here is a demonstration:

msedge_prwsHOQhvG

signal.addEventListener('abort', () => {
descriptionBanner.remove();
});

signal.addEventListener('abort', () => {
disabledBanner.remove();
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now I think why not unload on soft-nav:render? Seems to work well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you reckon that we can proceed without these two early events

We can't. Neither the turbo:before-fetch-request nor the turbo:visit events are fired in the test cases I provided in the PR description

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now I think why not unload on soft-nav:render?

I've let this idea marinate in my head, and I think it's too risky

@SunsetTechuila
SunsetTechuila marked this pull request as draft February 3, 2026 22:47
SunsetTechuila added a commit that referenced this pull request Feb 3, 2026
To see the issue or test the fix:

1. Rebase this branch on #8881
2. Go to #4008
3. Hover the first mention
4. Click #3980
@fregante

Copy link
Copy Markdown
Member

I'm planning to release 26.3.14, this PR won't make the cut so don't force yourself to finish it

@SunsetTechuila

SunsetTechuila commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Current status of this PR:

Next steps:

  • Replace at least the soft-nav:start listener with soft-nav:render. We might also want to remove turbo:before-fetch-request
  • After that, we need to do extensive testing to make sure nothing breaks

@fregante

fregante commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

Judging by #6554 (comment), this wouldn't be enough, at least for navigations that keep the same layout

The main issue is that the DOM is no longer actually re-generated:

  1. our selector observer tags a "seen" element
  2. after a page change the element is never removed
  3. no add callback is ever fired

It could cover at least some page transitions though, like issue list -> issue

@SunsetTechuila

Copy link
Copy Markdown
Contributor Author

Some features should be updated to take advantage of it (e.g. rgh-feature-descriptions - see https://github.com/refined-github/refined-github/tree/rgh-feat-desc)

@fregante

fregante commented Jun 5, 2026

Copy link
Copy Markdown
Member

Right, but that has always been the issue.

  1. User navigates to Locked issue sandbox#74
  2. locked-issue is appended
  3. User navigates to a different issue via direct link
  4. The state label is left behind

I think this is doesn't happen for just one or two features. Any feature that appends or even alters DOM is going to be affected.

We can still try this PR (or #6905 depending on which one has the closest timing) and then address the individual issues as they come up.

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.

2 participants