Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add repo file tree item link behavior#34730

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@bytedream
Copy link
Contributor

@bytedreambytedream commentedJun 15, 2025
edited
Loading

Converts the repo file tree items into<a> elements to have default link behavior. Dynamic content load is still done when no special key is pressed while clicking on an item.

eric-j-ason reacted with thumbs up emoji
@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelJun 15, 2025
@lunnylunny added type/enhancementAn improvement of existing functionality topic/uiChange the appearance of the Gitea UI labelsJun 15, 2025
@lunnylunny added this to the1.25.0 milestoneJun 15, 2025
@wxiaoguang
Copy link
Contributor

It should also follow the browser's default behavior:Ctrl+Click /Command+Click means "Open in New Window"

@bytedream
Copy link
ContributorAuthor

Done, thanks for pointing this out

@wxiaoguang
Copy link
Contributor

By doing some searches, I think "middle key" is not a widely used approach to "open a new window". I do not see browsers officially support it.

The widely supported approach is "Ctrl+LeftClick"

@wxiaoguang
Copy link
Contributor

If you'd like to support "middle click", the ideal approach can be like this:

  • make the items to be real<a> links, then middle-click works for users by default.
  • use our@click handler to handlectrl/meta keys, and stop the default link's behavior.

@silverwind
Copy link
Member

silverwind commentedJun 17, 2025
edited
Loading

I think we should just render a native<a> element and onlypreventDefault theclick event withbutton 0, while letting the browser handle all other interactions.

This way, stuff like middle click, ctrl+click, cmd+click will all work natively and don't even need explicit handlers.

@wxiaoguang
Copy link
Contributor

I think we should just render a native<a> element and onlypreventDefault theclick event withbutton 0, while letting the browser handle all other interactions.

This way, stuff like middle click, ctrl+click, cmd+click will all work natively and don't even need explicit handlers.

The same as#34730 (comment) ? Or is there something I missed?

@silverwind
Copy link
Member

silverwind commentedJun 17, 2025
edited
Loading

I think we should just render a native<a> element and onlypreventDefault theclick event withbutton 0, while letting the browser handle all other interactions.
This way, stuff like middle click, ctrl+click, cmd+click will all work natively and don't even need explicit handlers.

The same as#34730 (comment) ? Or is there something I missed?

Basically the same, but I guess the code still need to check whether any modifier key is held, and onlye.preventDefault when none are because deciding only one.button is not enough.

wxiaoguang reacted with thumbs up emoji

@wxiaoguang
Copy link
Contributor

I see, maybe ideally it could be like this:

  • use<a> for tree items with real links.
  • if no ctrl/meta/alt key, then use our "fetch" to load the file view content without reload, and preventDefault.
  • otherwise, we do nothing and leave the work to the browser.

@silverwind
Copy link
Member

silverwind commentedJun 17, 2025
edited
Loading

Yes, so basically:

if(e.button!==0||e.ctrlKey||e.metaKey||e.altKey||e.shiftKey){return;// let browser handle the click}e.preventDefault();// update view to clicked file

MaybeshiftKey can be removed, I'm not aware of any special functionality tied to it.altKey is useful for text selection within a link.

@bytedream
Copy link
ContributorAuthor

Thanks for the suggestions, I've updated the PR accordingly by using<a> tags.

By doing some searches, I think "middle key" is not a widely used approach to "open a new window". I do not see browsers officially support it.

Interesting, I almost exclusively use the middle click to open links and such in a new tab.

Maybe shiftKey can be removed, I'm not aware of any special functionality tied to it. altKey is useful for text selection within a link.

Shift+LeftClick opens the link in a new browser window, so I've kept it.

silverwind reacted with thumbs up emoji

@silverwind
Copy link
Member

Yes, we need to keep all modifiers, they all have a purpose and mine opens new window on shift+click too. middle click and ctrl+click are both known to me, so they are not so obscure :)

@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelsJun 19, 2025
@lunny
Copy link
Member

It seems when a subtree is loaded, the whole screen flashes briefly.

@bytedream
Copy link
ContributorAuthor

Fixed

@GiteaBotGiteaBot added lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1This PR needs approval from one additional maintainer to be merged. labelsJun 19, 2025
@lunnylunny added the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 19, 2025
@wxiaoguangwxiaoguang merged commit7346ae7 intogo-gitea:mainJun 19, 2025
26 checks passed
@GiteaBotGiteaBot removed the reviewed/wait-mergeThis pull request is part of the merge queue. It will be merged soon. labelJun 19, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull requestJun 20, 2025
* giteaofficial/main:  [skip ci] Updated translations via Crowdin  Add ff_only parameter to POST /repos/{owner}/{repo}/merge-upstream (go-gitea#34770)  Add repo file tree item link behavior (go-gitea#34730)  Fix tag target (go-gitea#34781)
@go-giteago-gitea locked asresolvedand limited conversation to collaboratorsSep 17, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@silverwindsilverwindsilverwind left review comments

@lunnylunnylunny approved these changes

@wxiaoguangwxiaoguangwxiaoguang approved these changes

Assignees

No one assigned

Labels

lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.modifies/frontendtopic/uiChange the appearance of the Gitea UItype/enhancementAn improvement of existing functionality

Projects

None yet

Milestone

1.25.0

Development

Successfully merging this pull request may close these issues.

5 participants

@bytedream@wxiaoguang@silverwind@lunny@GiteaBot

[8]ページ先頭

©2009-2025 Movatter.jp