Repository navigation
Enable native hovercards when linkifying issues - #5414
Conversation
| baseUrl: '', | ||
| ...options, | ||
| attributes: { | ||
| rel: 'noreferrer noopener', |
There was a problem hiding this comment.
Unnecessary for issue (internal) links
| // Enable native issue title fetch | ||
| for (const link of linkified.children as HTMLCollectionOf<HTMLAnchorElement>) { | ||
| const issue = link.href.split('/').pop(); | ||
| link.setAttribute('class', 'issue-link js-issue-link tooltipped tooltipped-ne'); |
There was a problem hiding this comment.
Without .tooltipped .tooltipped-ne, .js-issue-link becomes meaningless as title tooltips can't display even if they are fetched. But this is what GitHub does and the tooltips are overridden anyway:
// https://github.githubassets.com/assets/app/assets/modules/github/issues/issue-link.ts
// Load issue/PR/discussion references to display the title for the tooltip from the server on hover.
// If hovercards are enabled for the referenced type on this part of the DOM,
// this behavior is bypassed in favor of the hovercard.| link.dataset.errorText = 'Failed to load issue title'; | ||
| link.dataset.permissionText = 'Issue title is private'; |
There was a problem hiding this comment.
Align with GitHub. Also this works for PRs so "issue" is not very precise.
| link.dataset.permissionText = 'Title is private'; | ||
| link.dataset.url = link.href; | ||
| link.dataset.id = `rgh-issue-${issue!}`; | ||
| link.dataset.hovercardType = 'issue'; |
There was a problem hiding this comment.
A small note: if [data-hovercard-type] is omitted (or if it also has [data-insert-type-here-hovercards-enabled]), it will unconditionally active.
Using issue is fine since it works and we can't know what type the conversation is without making a request.
| link.dataset.url = link.href; | ||
| link.dataset.id = `rgh-issue-${issue!}`; | ||
| link.dataset.hovercardType = 'issue'; | ||
| link.dataset.hovercardUrl = `${link.pathname}/hovercard`; |
There was a problem hiding this comment.
I've said this before but: GitHub's routing is super-duper smart so it works even if the path has a trailing slash.
cheap-glitch
left a comment
There was a problem hiding this comment.
Successfully tested on Firefox
Part of #5052
Test URLs
https://github.com//refined-github/refined-github/blob/80e42b31dc33338d3ae12092d67fa8bc6f6d5161/source/features/github-bugs.css#L6
Screenshot