Skip to content

default-branch-button implemented by GitHub #8662

Closed

Description

@FloEdelmann

Activity

  1. fregante commented on Sep 5, 2025

    @fregante
    Member

    That's fantastic! I'm glad they copied the exact style too.

    We need to be careful when removing this feature because the behaviors might be different and definitely the "non-default branch blue highlight" is missing. So at the very least we need to introduce a new non-default-branch feature or something

  2. fregante commented on Sep 5, 2025

    @fregante
    Member

    I'm not seeing it yet, can you find a selector that matches our button IF there's a native button next to it? Most likely something like:

    .rgh-default-branch-button:nth-last-child(3)

    or

    .rgh-default-branch-button:nth-child(2)

    depending on the final structure. I'll add a CSS hotfix to hide it for now.

  3. FloEdelmann commented on Sep 5, 2025

    @FloEdelmann
    MemberAuthor

    Unfortunately, it's not that easy 🥲

    #repos-file-tree div:has(> a[data-component="IconButton"]) + div > .rgh-default-branch-button-group > .rgh-default-branch-button {
        display: none;
    }
  4. fregante commented on Sep 5, 2025

    @fregante
    Member

    Can you post the DOM of the 3 buttons?

    Image
  5. FloEdelmann commented on Sep 5, 2025

    @FloEdelmann
    MemberAuthor
    HTML
    <div class="ReposFileTreePane-module__Box_3--XDLn8">
      <div
        class="ReposFileTreePane-module__FullWidthButtonGroup--avF6A prc-ButtonGroup-ButtonGroup-vcMeG">
        <div>
          <a
            data-component="IconButton"
            type="button"
            class="prc-Button-ButtonBase-c50BI prc-Button-IconButton-szpyj"
            data-loading="false"
            data-no-visuals="true"
            data-size="medium"
            data-variant="default"
            aria-describedby=":R6m6mplab:-loading-announcement"
            aria-labelledby=":Rm6mplab:"
            href="/refined-github/refined-github/blob/main/source/features/default-branch-button.tsx"
            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-cYMVY"
            data-direction="s"
            aria-hidden="true"
            id=":Rm6mplab:"
            popover="auto">
            View file on default branch
          </span>
        </div>
        <div>
          <div class="BtnGroup d-flex rgh-default-branch-button-group">
            <a
              class="btn tooltipped tooltipped-se px-2 rgh-default-branch-button flex-self-start BtnGroup-item"
              href="https://github.com/refined-github/refined-github/blob/main/source/features/default-branch-button.tsx"
              aria-label="See this view on the default branch">
              <svg
                class="octicon octicon-chevron-left"
                xmlns="http://www.w3.org/2000/svg"
                width="16"
                height="16"
                viewBox="0 0 16 16"
                role="img"
                aria-hidden="true">
                <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>
            <button
              style="min-width: 0"
              type="button"
              aria-haspopup="true"
              aria-expanded="false"
              tabindex="0"
              aria-label="monospace-textareas branch"
              data-testid="anchor-button"
              class="prc-Button-ButtonBase-c50BI react-repos-tree-pane-ref-selector width-full ref-selector-class RefSelectorAnchoredOverlay-module__RefSelectorOverlayBtn--D34zl rgh-seen-131294625 rgh-highlight-non-default-branch BtnGroup-item rounded-left-0"
              data-loading="false"
              data-size="medium"
              data-variant="default"
              aria-describedby="ref-picker-repos-header-ref-selector-loading-announcement"
              id="ref-picker-repos-header-ref-selector"
              data-hotkey="w">
              <span
                data-component="buttonContent"
                data-align="center"
                class="prc-Button-ButtonContent-HKbr-">
                <span data-component="text" class="prc-Button-Label-pTQ3x">
                  <div
                    class="RefSelectorAnchoredOverlay-module__RefSelectorOverlayContainer--mCbv8">
                    <div
                      class="RefSelectorAnchoredOverlay-module__RefSelectorOverlayHeader--D4cnZ">
                      <svg
                        aria-hidden="true"
                        focusable="false"
                        class="octicon octicon-git-branch"
                        viewBox="0 0 16 16"
                        width="16"
                        height="16"
                        fill="currentColor"
                        display="inline-block"
                        overflow="visible"
                        style="vertical-align: text-bottom">
                        <path
                          d="M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"></path>
                      </svg>
                    </div>
                    <div
                      class="ref-selector-button-text-container RefSelectorAnchoredOverlay-module__RefSelectorBtnTextContainer--yO402">
                      <span
                        class="RefSelectorAnchoredOverlay-module__RefSelectorText--bxVhQ">
                        &nbsp;
                        <!-- -->
                        monospace-textareas
                      </span>
                    </div>
                  </div>
                </span>
                <span
                  data-component="trailingVisual"
                  class="prc-Button-Visual-2epfX prc-Button-VisualWrap-Db-eB">
                  <svg
                    aria-hidden="true"
                    focusable="false"
                    class="octicon octicon-triangle-down"
                    viewBox="0 0 16 16"
                    width="16"
                    height="16"
                    fill="currentColor"
                    display="inline-block"
                    overflow="visible"
                    style="vertical-align: text-bottom">
                    <path
                      d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path>
                  </svg>
                </span>
              </span>
            </button>
          </div>
          <button
            hidden=""
            data-testid="ref-selector-hotkey-button"
            data-hotkey-scope="read-only-cursor-text-area"
            data-hotkey="w"></button>
        </div>
      </div>
    </div>
  6. fregante commented on Sep 5, 2025

    @fregante
    Member

    Try this in your CSS field

    :nth-child(2) > .rgh-default-branch-button-group .rgh-default-branch-button {
      display: none;
    }
  7. FloEdelmann commented on Sep 5, 2025

    @FloEdelmann
    MemberAuthor

    Yep, that works 👍🙂

  8. fregante commented on Sep 5, 2025

    @fregante
    Member

    Hotfix sent.

    Next:

    • detect native button in default-branch-button
    • extract non-default-branch feature from default-branch-button;
      Highlights non-default-branch, potentially CSS only, using a selector like in the hotfix
    • in March 2026, drop default-branch-button

    I sent some feedback to GitHub as well: https://github.com/orgs/community/discussions/172354#discussioncomment-14317974

  9. added
    small
    and removed on Sep 5, 2025
  10. kidonng commented on Sep 6, 2025

    @kidonng
    Member

    It seems the native one only shows in file tree and for files, i.e. RGH still offer this one next to the breadcrumb:

    Image

    And folders:

    Image
  11. 1 remaining item

  12. fregante commented on Sep 6, 2025

    @fregante
    Member

    So let's only do this.

    I'm updating the hotfix because the selector is hiding our button (the only button) here:

    Image
  13. kidonng commented on Mar 25, 2026

    @kidonng
    Member

    We now also have a native button for folders in addition to files, but somehow it's wrong about whether the folder exists or not:

    Image

    Not sure if this is a bug or limitation on their side.

  14. fregante commented on Mar 25, 2026

    @fregante
    Member

    Can you provide a test link? It's weird that they'd be wrong about it.

    There are several ways we can go about it:

    • hide our button, regardless of their bug
    • hide their button due to their bug
    • enhance their button (not really worth it since it's easier to hide theirs)
  15. kidonng commented on Mar 25, 2026

    @kidonng
    Member
  16. fregante commented on Mar 25, 2026

    @fregante
    Member

    Oh got it, it doesn't work for any folder. This is most likely because folders don't exist in git and they implemented it naively. It would be good to report it to them.

  17. fregante commented on Mar 25, 2026

    @fregante
    Member

    How about this: we replace their button only if it's dimmed/disabled.

    So the logic would look something like:

    1. Add button if the native one doesn't exist or is not disabled
    2. Always remove natively-disabled button

    I don’t think a disabled button is ever useful, it's better to lead the user to the 404 page and there they can find more actions for the file.

    This way the feature will continue to exist as an enhancement of the native button.

  18. self-assigned this
    on May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedbugsmall

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions