-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix navigation issues in file explorer #6552
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ import features from '../feature-manager'; | |
import observe from '../helpers/selector-observer'; | ||
|
||
function add(folderDropdown: HTMLElement): void { | ||
folderDropdown.parentElement!.querySelector('a.rgh-download-folder-button')?.remove(); | ||
|
||
const downloadUrl = new URL('https://download-directory.github.io/'); | ||
downloadUrl.searchParams.set('url', location.href); | ||
|
||
|
@@ -24,14 +26,16 @@ function add(folderDropdown: HTMLElement): void { | |
|
||
function init(signal: AbortSignal): void { | ||
observe([ | ||
'[title="More options"]', | ||
'[title="More options"]', // PageDetect.isRepoTree | ||
'[title="More file actions"]', // PageDetect.isSingleFile | ||
'[aria-label="Add file"] + details', // TODO: Drop in mid 2023. Old file view #6154 | ||
], add, {signal}); | ||
} | ||
|
||
void features.add(import.meta.url, { | ||
include: [ | ||
pageDetect.isRepoTree, | ||
pageDetect.isSingleFile, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a hack, a feature should not be enabled on random pages just to cleanup after itself There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but add singleFile is needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feature must appear exclusively on directories because it downloads directories and the It's only "needed" here because the feature manager is broken, but it's still a hack that we should not use |
||
], | ||
exclude: [ | ||
pageDetect.isRepoRoot, // Already has an native download ZIP button | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these events are called when clicking one of the repos tabs, for example when you click on Issues. This means you're running every feature twice on every page load.
Also, neither one is called when you:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ironically this feature is being duplicated here because our selector observer keeps working regardless of page changes, so it targets the "More options" dropdown every time React (mistakenly) regenerates it.
I might push a fix specific to this feature, but the lack of a global file listener is still unresolved. I think that as a starter, we need to replace
turbo:render
withsoft-nav:render
. Then maybe we can address the lack of browser history support by addingpopstate
listeners, but those need to be deduplicated whensoft-nav:render
is also fired.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I "fixed the duplication" by using
[title="More options"]:not(:has(+ .rgh-download-folder-button))
, but this means that the old button is left in place, pointing to the old folder. 🥲Let's move the discussion to: