Skip to content

expand-collapse-files-buttons - New feature - #9347

Closed
simonepri wants to merge 4 commits into
refined-github:mainfrom
simonepri:expand-collapse-files-buttons
Closed

simonepri wants to merge 4 commits into
refined-github:mainfrom
simonepri:expand-collapse-files-buttons

Conversation

@simonepri

@simonepri simonepri commented May 6, 2026 •

Copy link
Copy Markdown

Closes #9346.

Adds two buttons — "Collapse all" and "Expand all" — to the PR Files toolbar, alongside the existing diff/file-filter controls. Same effect the modifier-click affordance in toggle-everything-with-alt already provides, just discoverable: no key combo to remember, no hidden hint.

  • Collapse all — clicks the chevron on every .js-file.Details--on
  • Expand all — first clicks every .js-diff-load (so GitHub-hidden large diffs actually load, not just reveal an empty header), then expands any remaining still-collapsed files

Selectors are snapshotted before each pass so the in-flight DOM swap of "Load diff" → diff body doesn't make the second pass re-collapse what was just opened.

Test URLs

Screenshot

image

simonepri added 4 commits May 6, 2026 07:51
## Problem

CI lint fails: `refined-github/no-optional-chaining` rejects the three
`$optional(...)?.click()` calls in `expandAll`/`collapseAll`.

## Solution

Switch to `$()` (which throws if not found) and drop `$optional`. The
queried elements are guaranteed by their parent selectors:

- `.js-diff-load` is matched via the `:has(.js-diff-load)` filter.
- `button.js-details-target` is the chevron always present on `.js-file`.

If GitHub ever changes that markup, throwing is the correct signal.
## Problem

The Collapse/Expand BtnGroup sat on the baseline while the surrounding
diffbar items render centered, so the new buttons looked offset.

## Solution

Add Primer's `flex-self-center` utility to the BtnGroup wrapper so it
aligns with the other toolbar items.
## Problem

CI's `validateReadme` test fails: `AssertionError: Should have a
screenshot (png/gif) in the readme`. The readme entry was added
without one because the buttons hadn't been built yet.

## Solution

Wrap the entry's description in a markdown link pointing to a
user-attachments PNG of the rendered toolbar, and update the matching
`screenshot` field in the auto-generated `features-meta.json`
snapshot so vitest doesn't flag it on the next run.
@simonepri
simonepri marked this pull request as ready for review May 6, 2026 07:18
@fregante fregante closed this May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Add visible "Collapse all" / "Expand all" diff buttons to PR Files page

2 participants