Skip to content

Add expand-all-collapsed-code feature - #2434

Merged
fregante merged 11 commits into
refined-github:masterfrom
Tiramisu77:master
Sep 18, 2019
Merged

fregante merged 11 commits into
refined-github:masterfrom
Tiramisu77:master

Conversation

@Tiramisu77

@Tiramisu77 Tiramisu77 commented Sep 12, 2019 •

Copy link
Copy Markdown
Contributor

Closes #2151

I used the easier solution of clicking on expand buttons until none left, with observing DOM changes via MutationObserver to trigger the subsequent clicks. I also included this script on single commit pages.

Test

Alt-click on any expand button on PR commit or single commit page. Try doing simple clicks and then alt-click.

Files tab on PRs: https://github.com/sindresorhus/refined-github/pull/2429/files
Single commits: 8a2c66c
PR commit: 8a2c66c


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


IssueHunt has been backed by the following sponsors. Become a sponsor

@fregante fregante left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes:

  • use for-of instead of forEach
  • don’t use subtree: true, listen to some GitHub events instead, or observe elements more selectively
  • if you need MutationObserver, declare one in the module’s scope and then .observe() elements later
  • use select-dom instead of querySelector*
  • use delegate-it instead of listening on each element

@Tiramisu77

Tiramisu77 commented Sep 14, 2019 •

Copy link
Copy Markdown
Contributor Author

Can you suggest to what events should I listen? I checked libs, but couldn't find anything that would work in this case.

Also, I'm not very experienced with Github, so I want to ask at what pages this feature should be present at. Ideally I would like to just get the necessary include:[] parameter for features.add()

Comment thread source/content.ts Resolved
@Tiramisu77
Tiramisu77 requested a review from fregante September 14, 2019 17:26
@fregante fregante changed the title Add expand-all-collapsed-code feature (#2151) Add expand-all-collapsed-code feature Sep 14, 2019

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's almost done ^__^

Thanks for the changes

Comment thread source/content.ts Resolved
Co-Authored-By: Federico Brigante <[email protected]>
Since there's only ever one element observed at once, the `mutations` array will only have one element.
@fregante

Copy link
Copy Markdown
Member

Thank you! This works correctly. On a slow connection it might take a bit to expand a whole file but it's not terribly annoying, just a bit slow.

@fregante
fregante merged commit ba46f76 into refined-github:master Sep 18, 2019
@kgagnon

kgagnon commented Nov 25, 2019

Copy link
Copy Markdown

Some distros have already alt click actions bound.
Could there be an alternative to this feature?

@fregante fregante mentioned this pull request Dec 18, 2019
@ashapir3

Copy link
Copy Markdown

I'm interested in that feature and as I see this has been merged I still can't unfold all folded files with ALT+click.
Could you please let me know what I am doing wrong?
BTW, I tried this on enterprize and on github.com.

@fregante

fregante commented Jan 22, 2020 •

Copy link
Copy Markdown
Member

It works for me on this very PR in the files tab

Make sure this feature does what you think it does. It only unfolds a single file, not all of them. Here's a demo:

Perhaps it should be renamed to expand-whole-file-from-diff

@ashapir3

Copy link
Copy Markdown

single works as in the demo, but the feature title says expand-all-collapsed-code
is github has a feature to unfold all of them? thanks.

@sfc-gh-ahamza

Copy link
Copy Markdown

It does not work for me, not even for a single file. I've tried Firefox and Chrome. Alt+mouse click on the icon within file only expands that one code block and only once. In order to see one entire file expanded I still have to repeatedly click the expand icon.

I've read through the comments above as well as the comments in #2151

@fregante

Copy link
Copy Markdown
Member

Refer to #3436 and #3472

@refined-github refined-github locked and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

Ability to expand all collapsed code in PR diffs

5 participants