default-branch-button - Avoid duplicate buttons#9148
Draft
SunsetTechuila wants to merge 2 commits intomainfrom
Draft
default-branch-button - Avoid duplicate buttons#9148SunsetTechuila wants to merge 2 commits intomainfrom
default-branch-button - Avoid duplicate buttons#9148SunsetTechuila wants to merge 2 commits intomainfrom
Conversation
9040e88 to
468ca33
Compare
SunsetTechuila
commented
Apr 3, 2026
Comment on lines
+45
to
+46
| const buttonGroup = branchSelector.closest('[class*="ButtonGroup"]') ?? undefined; | ||
| const nativeButton = $optional('[type="button"]:has(> .octicon-chevron-left)', buttonGroup); |
Member
Author
There was a problem hiding this comment.
Or
const nativeButtonLabel = 'View file on default branch';
const nativeButton = getElementByAriaLabelledBy('a[data-component="IconButton"]', nativeButtonLabel)
?? $optional('button[aria-label="${nativeButtonLabel}"]');
if (nativeButton?.ariaDisabled === 'false') {
return;
}
Member
Author
There was a problem hiding this comment.
Disabled button:
HTML
<div>
<button
aria-disabled="true"
data-component="IconButton"
type="button"
aria-label="View file on default branch"
class="prc-Button-ButtonBase-9n-Xk prc-Button-IconButton-fyge7"
data-inactive="true"
data-loading="false"
data-no-visuals="true"
data-size="medium"
data-variant="default"
aria-describedby="_R_5hlmjal1d_"
>
<svg
aria-hidden="true"
focusable="false"
class="octicon octicon-chevron-left"
viewBox="0 0 16 16"
width="16"
height="16"
fill="currentColor"
display="inline-block"
overflow="visible"
style="vertical-align:text-bottom"
>
<path d="M9.78 12.78a.75.75 0 0 1-1.06 0L4.47 8.53a.75.75 0 0 1 0-1.06l4.25-4.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L6.06 8l3.72 3.72a.75.75 0 0 1 0 1.06Z"></path>
</svg>
</button>
<span
class="prc-TooltipV2-Tooltip-tLeuB"
data-direction="se"
role="tooltip"
aria-hidden="true"
id="_R_5hlmjal1d_"
popover="auto"
style="top: 200px; left: 16px;"
>
File does not exist on default branch
</span>
</div>;Enabled:
HTML
<div>
<a
data-component="IconButton"
type="button"
class="prc-Button-ButtonBase-9n-Xk prc-Button-IconButton-fyge7"
data-loading="false"
data-no-visuals="true"
data-size="medium"
data-variant="default"
aria-labelledby="_R_5hlmjal1d_"
href="/refined-github/refined-github/blob/main/.ncurc.json"
data-discover="true"
>
<svg
aria-hidden="true"
focusable="false"
class="octicon octicon-chevron-left"
viewBox="0 0 16 16"
width="16"
height="16"
fill="currentColor"
display="inline-block"
overflow="visible"
style="vertical-align: text-bottom;"
>
<path d="M9.78 12.78a.75.75 0 0 1-1.06 0L4.47 8.53a.75.75 0 0 1 0-1.06l4.25-4.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L6.06 8l3.72 3.72a.75.75 0 0 1 0 1.06Z"></path>
</svg>
</a>
<span
class="prc-TooltipV2-Tooltip-tLeuB"
data-direction="se"
aria-hidden="true"
id="_R_5hlmjal1d_"
popover="auto"
style="top: 200px; left: 16px;"
>
View file on default branch
</span>
</div>;
SunsetTechuila
commented
Apr 3, 2026
| async function add(branchSelector: HTMLElement): Promise<void> { | ||
| const buttonGroup = branchSelector.closest('[class*="ButtonGroup"]') ?? undefined; | ||
| const nativeButton = $optional('[type="button"]:has(> .octicon-chevron-left)', buttonGroup); | ||
| if (nativeButton?.ariaDisabled !== 'true') { |
Member
Author
There was a problem hiding this comment.
Enabled button doesn't have the "aria-disabled" attribute
72023f3 to
57f3246
Compare
fregante
approved these changes
Apr 3, 2026
Member
Author
|
No, this should be done with CSS |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #8662
Test URLs
https://github.com/refined-github/refined-github/tree/unread-in-backgr0und/source
https://github.com/refined-github/refined-github/blob/5c41c2983e0dc7b420b1598f5525949e371f7e99/.ncurc.json
Screenshot