-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Load features when navigating between React-based pages #8881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 6880958.
|
| function linkifyIssue(paragraph: HTMLParagraphElement): void { | ||
| // Already linkified | ||
| if (elementExists('a', paragraph)) { | ||
| logError(new Error(`${paragraph.textContent} is already linkified`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? This change seems to suggest that features will now run multiple times on the same view.
The PR also seems to add a listener for the "render" but not for the "unload", causing all features to potentially be inited multiple times. What happens if I call observe('a');observe('a') for example? I think it's deduplicated almost correctly, but then does the abort signal work well?
The alternative could be to also unload the features on "soft nav react bye" if it exists, but then most likely we'll get flickering from features coming and going.
I think a quick way to test whether the PR works as-is would be to open the Task Manager and go back and forth between React tabs. If the page doesn't leak and slow down considerably after 50 back and forth, then we should be good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR also seems to add a listener for the "render" but not for the "unload", causing all features to potentially be
inited multiple times.
No, features are unloaded correctly, you don't need to listen for any new events
refined-github/source/feature-manager.tsx
Lines 129 to 130 in 5f6060f
| document.addEventListener('turbo:before-fetch-request', unloadAll); // Clicks | |
| document.addEventListener('turbo:visit', unloadAll); // Back/forward button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally you won't see this error, but it can happen if you try hard enough
To reproduce:
- Open a repo's issue list
- Open an issue
- Click the Issues navbar tab
- Hit the browser back button to return to the issue
Timings are important - you've to be fast, but not too fast. Usually takes me 2-3 tries. Сan't say for sure yet what exactly is happening and why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, features are unloaded correctly, you don't need to listen for any new events
refined-github/source/feature-manager.tsx
Lines 129 to 130 in 5f6060f
document.addEventListener('turbo:before-fetch-request', unloadAll); // Clicks document.addEventListener('turbo:visit', unloadAll); // Back/forward button
This is no longer true (but certainly was)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Navigation API should now be available cross browser, I'm just afraid it fires too often. Worth a check too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked to see if we could hook some function to emit custom navigation events, but none of the breakpoints I set on navigation-related functions were hit. I might be missing something, though. If you want to check for yourself, the ReactAppElement source is a good starting point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but none of the breakpoints I set on navigation-related functions were hit
Managed to hit them - the functions are being used, just not when navigating from the issue list to an issue page
| } | ||
| }); | ||
| } while (await oneEvent(document, 'turbo:render')); | ||
| } while (await oneEvent(document, ['turbo:render', 'soft-nav:react-done'])); |
There was a problem hiding this comment.
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


partially _fixes #6554
Test URLs
https://github.com/refined-github/refined-github/issues -> issue -> go back
Screenshot