Skip to content

rgh-feature-descriptions - Update on React navigation - #9860

Merged
fregante merged 12 commits into
mainfrom
url
Jul 31, 2026
Merged

fregante merged 12 commits into
mainfrom
url

Conversation

@fregante fregante added the bug label Jul 18, 2026
@github-actions github-actions Bot added the meta Related to Refined GitHub itself label Jul 18, 2026
@fregante fregante removed the meta Related to Refined GitHub itself label Jul 18, 2026
@github-actions github-actions Bot added the meta Related to Refined GitHub itself label Jul 18, 2026

@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.

So good when it all comes together. The url store is the first piece towards full React navigation support (#6554)

isRefinedGitHubRepo,
pageDetect.isNewIssue,
// TODO: Replace with "is bug report template"
() => Boolean(getFeatureNameFromIssueTitle()),

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 dynamic part doesn't yet work on the "new issue" form. I'll probably have to extract a further store like currentFeature that listens to both url and issueTitleInputElement

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 unchanged. It's not a bug though, it just means that the widget only appears when landing on the bug report from

const newIssueUrl = new URL('https://github.com/refined-github/refined-github/issues/new');
newIssueUrl.searchParams.set('template', '1_bug_report.yml');

@fregante fregante removed the meta Related to Refined GitHub itself label Jul 18, 2026
@github-actions github-actions Bot added the meta Related to Refined GitHub itself label Jul 18, 2026
@fregante
fregante marked this pull request as draft July 19, 2026 09:33
@SunsetTechuila

Copy link
Copy Markdown
Contributor

Just a quick heads-up: are you aware that the init function runs each time the active file is changed?

@fregante

Copy link
Copy Markdown
Member Author

Thanks, yeah, in this case it's fine because delegate and observe calls are deduplicated. Also since the rgh-seen classes aren't removed, the component isn't re-mount()ed either

Comment thread source/components/url.ts
Comment on lines +3 to +12
function stripHash(url: string): string {
const u = new URL(url);
u.hash = '';
return u.href;
}

const urlStore = readable(stripHash(location.href), set => {
const handler = (event: NavigateEvent): void => {
set(stripHash(event.destination.url));
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wouldn't this make more sense?

Suggested change
function stripHash(url: string): string {
const u = new URL(url);
u.hash = '';
return u.href;
}
const urlStore = readable(stripHash(location.href), set => {
const handler = (event: NavigateEvent): void => {
set(stripHash(event.destination.url));
};
const urlStore = readable(getCleanPathname(), set => {
const handler = (event: NavigateEvent): void => {
const pathname = getCleanPathname(new URL(event.destination.url));
set(pathname);
};

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.

LGTM

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.

Unfortunately cannot, rgh-feature-descriptions already uses the URL parameters

@fregante

Copy link
Copy Markdown
Member Author

I did just realize I found a bug caused by #9830 in here though:

function onFieldKeydown(selector: string | readonly string[], callback: KeydownHandler, signal: AbortSignal): void {
delegate<TextField, 'keydown'>(selector, 'keydown', event => {
const field = event.delegateTarget;
if (
event.isComposing
// New autocomplete dropdown
|| field.hasAttribute('aria-autocomplete')
// Classic autocomplete dropdown
|| elementExists('.suggester', field.form!)
) {
return;
}
callback(event);
}, {
// Adds support for `esc` key; GitHub seems to use `stopPropagation` on it
capture: true,
signal,
});
}

because this specific delegate call is not deduplicated.

@SunsetTechuila

Copy link
Copy Markdown
Contributor

The reason I wanted to merge #8881 with feature unloading was to avoid managing dynamic UI like this. I find recreating the UI on navigation to be a preferable solution due to its lower complexity. Based on this PR, I assume you have a different opinion

@fregante

fregante commented Jul 19, 2026 •

Copy link
Copy Markdown
Member Author

I find recreating the UI on navigation

That was the idea initially but that would require cleaning up everything, including rgh-seen and all the elements that were appended to the dom, which still isn't a solved problem—and tbh, it sounds more complex than self-updating features.

@fregante

Copy link
Copy Markdown
Member Author

feature unloading

I think this is still ideal or required in some situations. #9865 fixes some related issues.

We'll most likely run into this again:

but I haven't noticed any severe issues since merging #9830, other than:

The bug fixes so far are straightforward:

  • more specific selectors
  • extract or memoize inline callbacks

I'll wait probably one more week before releasing this, looking for more bugs. After that, I will likely implement unloading via either popstate as you did or just in time before calling the inits (unload then init)

@fregante

fregante commented Jul 20, 2026 •

Copy link
Copy Markdown
Member Author

(Comment extracted to #9893)

@fregante

Copy link
Copy Markdown
Member Author

The singleton works perfectly to avoid infinite memory leaks. It does not unload the component when the user navigates away from the files view though, but the url store/listener is pretty minimal in that case anyway.

Will continue the exploration in #9893

@fregante
fregante marked this pull request as ready for review July 31, 2026 10:37
@fregante
fregante merged commit 0f8f36c into main Jul 31, 2026
14 checks passed
@fregante
fregante deleted the url branch July 31, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

2 participants