Fix sticky file header tooltips#1581
Conversation
| } | ||
|
|
||
| if (pageDetect.isSingleFile() || pageDetect.isPRFiles()) { | ||
| enableFeature(fixStickyFileHeaderTooltips); |
There was a problem hiding this comment.
I'm not sure if this the right place to call this script, or even if the script should be added to /features, because this isn't necessarily a "feature", but rather a fix for another feature – the sticky file-header, that is. Any thoughts?
There was a problem hiding this comment.
That's right, I think if this PR gets accepted, it will have to becomes its own feature: sticky-file-headers or even just sticky-headers that injects the CSS
and also fixes the issues it causes.
That, as previously mentioned, only if it's too much trouble to fix with CSS alone, which would be preferable.
There was a problem hiding this comment.
That, as previously mentioned, only if it's too much trouble to fix with CSS alone, which would be preferable.
This is very interesting! I can't think of any way to get around this issue with CSS alone, and if there is a way to do it, I don't think it would be as straightforward as the JS approach of flipping the tooltip class names from "north" to "south".
What I don't like about this PR so far is the fact that the current implementation/script fix-sticky-file-header-tooltips isn't a feature!
I think if this PR gets accepted, it will have to become its own feature: sticky-file-headers or even just sticky-headers that injects the CSS
I very much like the idea of encapsulating everything about the sticky headers to its own feature! Thanks for suggesting it! 🙇
That said, a feature like that requires CSS. The challenge here is that: A) currently all CSS live in one place, and B) there is no easy way to tie CSS to the script of a specific feature.
Having something like that is not a very bad idea, IMO! I have given this some thoughts, and I have some ideas that I'd like to share in a separate issue outside this PR since this conversation could apply to any feature, not just this one.
| const oppositeDirections = { | ||
| 'tooltipped-n': 'tooltipped-s', | ||
| 'tooltipped-ne': 'tooltipped-se', | ||
| 'tooltipped-nw': 'tooltipped-sw' |
There was a problem hiding this comment.
|
I also noticed that some related tooltips were intentionally removed (#689 (comment), #799, #1234) to get around this issue. Could we use this workaround/idea instead, and restore some of those tooltips? Proof of concept: [aria-label='Edit comment']::after,
- [aria-label='Open this file in GitHub Desktop']::before,
- [aria-label='Open this file in GitHub Desktop']::after,
[aria-label$='branch to make changes.']::before, |
|
|
||
| export default function () { | ||
| for (const el of select.all('.file-header [class*=tooltipped-n]')) { | ||
| let direction; |
There was a problem hiding this comment.
Lo-fi one-liner to replace everything in this loop
el.className = el.className.replace('tooltipped-n', 'tooltipped-s');There was a problem hiding this comment.
I like how explicit the current implementation is, but I understand that it might be a bit too verbose. 👍
I'll replace it with your suggestion, and probably add some comments for future maintainers to explain what it's exactly doing and emphasizing that we're replacing all north directions, not just "n" to "s", especially that, at a glance, el.className.replace looks very close to el.classList.replace but it behaves very differently.
| [aria-label='Open this file in GitHub Desktop']::before, | ||
| [aria-label='Open this file in GitHub Desktop']::after, | ||
| [aria-label$='branch to make changes.']::before, | ||
| [aria-label$='branch to make changes.']::after, |
There was a problem hiding this comment.
Since I got a thumbs up from @bfred-it on #1581 (comment), I went ahead and reverted all existing overrides that were hiding the tooltips.
Tooltips should look like this now 🎉
There was a problem hiding this comment.
The last two can still be hidden. The tool tips don’t add any more information and the icons are obvious.
There was a problem hiding this comment.
The last two can still be hidden.
I agree 👌. While most of the tooltips listed there (now removed) were added because of this specific issue within file-header, some other tooltips, like the notification indicator for example, can be redundant.
There was a problem hiding this comment.
All of these selectors should be restored, the icons are self-explanatory:
[aria-label^='View the whole file']::before,
[aria-label^='View the whole file']::after,
[aria-label^='Change this file']::before,
[aria-label^='Change this file']::after,
[aria-label='Delete this file']::before,
[aria-label='Delete this file']::after,
[aria-label='Edit this file']::before,
[aria-label='Edit this file']::after,|
A couple of things I'd rather see:
|
|
oooh absolutely! good catch on the first point! I'll also rename the |
|
Better yet... this whole feature can be left in the CSS by just overriding the position via CSS: .file-header [class*=tooltipped-n]:before,
.table-list-header [class*=tooltipped-n]:before {
top: auto !important;
bottom: -5px !important;
transform: rotate(180deg)
}
.file-header [class*=tooltipped-n]:after,
.table-list-header [class*=tooltipped-n]:after {
top: 100% !important;
bottom: auto !important;
margin-top: 5px !important;
} |
|
Aside from making this whole a thing its own feature, which isn't a bad idea. I'm curious, why do you think that approach ☝️ is better than the following? for (const el of select.all('.file-header [class*=tooltipped-n]')) {
el.className = el.className.replace('tooltipped-n', 'tooltipped-s');
}I feel like renaming |
| pageDetect.isPRSearch() || | ||
| pageDetect.isSingleFile() | ||
| ) { | ||
| enableFeature(makeHeadersSticky); |
There was a problem hiding this comment.
I'll move this to the top of ajaxedPagesHandler since the original styles were applied globally anyways. I don't think there's a need to limit this to certain pages.
That's indeed a problem, but that also applies to JavaScript code and that usually requires more work to fix anyway. The CSS-only solution is indeed "dirtier" (like my earlier suggestion to use That said, the latest iteration of your PR seems rather lean so let's see what others say. |
|
Cool! I don't necessarily disagree with any of that. Like you said, the CSS solution does feel a bit dirtier (idk, all those I'm very happy with how this PR has turned out! Thanks a lot for the help! :) I look forward to others feedback as well! |
fregante
left a comment
There was a problem hiding this comment.
After this change it can be merged.
| [aria-label='Open this file in GitHub Desktop']::before, | ||
| [aria-label='Open this file in GitHub Desktop']::after, | ||
| [aria-label$='branch to make changes.']::before, | ||
| [aria-label$='branch to make changes.']::after, |
There was a problem hiding this comment.
All of these selectors should be restored, the icons are self-explanatory:
[aria-label^='View the whole file']::before,
[aria-label^='View the whole file']::after,
[aria-label^='Change this file']::before,
[aria-label^='Change this file']::after,
[aria-label='Delete this file']::before,
[aria-label='Delete this file']::after,
[aria-label='Edit this file']::before,
[aria-label='Edit this file']::after,|
Thanks for fixing, @wsmd :) |






There's a minor issue causing tooltips of elements in the sticky file header (
.file-header) to be cut-off. This happens because of thestickyposition that Refined Github applies to the header.A single file
Pull Request files
Solution
This PR attempts to resolve the issue by adding a workaround that reverses the direction of the tooltips. This only applies to:
https://github.com/sindresorhus/refined-github/blob/f8abd1e5d7c9d3b45bf3f49e58244e01b22938ca/source/content.css#L666-L668
https://github.com/sindresorhus/refined-github/blob/f8abd1e5d7c9d3b45bf3f49e58244e01b22938ca/source/content.css#L673-L675
After
Closes #1295 (also see: #1308, #689)