-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add repo file tree middle click open #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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
It should also follow the browser's default behavior: |
Done, thanks for pointing this out |
@@ -68,6 +72,7 @@ const doGotoSubModule = () => { | |||
:class="{'selected': selectedItem === item.fullPath}" | |||
:title="item.entryName" | |||
@click.stop="doLoadFileContent" | |||
@click.middle.stop="doLoadFileContent" |
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.
Everything is handled in @click.stop
, so the @click.middle.stop
should be removed?
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.
@click.stop
does not fire for aux clicks. @click.middle.stop
is transformed into a mousup
event by vue internally, which is able to recognize aux clicks. @auxclick.stop
also exists, but Safari only added support for it lately, so it may not work for some users with older browsers.
@click.stop
only fires if the click is released on the same button where it was pressed. The mouseup event always fires when the click is released, regardless of the starting point. This difference in behavior is why I didn't unify both handlers into a single @mouseup.stop
.
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.
@click.stop
only fires if the click is released on the same button where it was pressed.
But that's the expected behavior.
For example, if you "mousedown" in a normal <a>
, then move mouse out, the link won't open.
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.
What I just wanted to say is that I didn't unify both calls into a mouseup because that would mess with the current behavior
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.
What would happen if "Ctrl+LeftClick"? I guess it won't trigger click.middle
?
@@ -94,6 +100,7 @@ const doGotoSubModule = () => { | |||
:class="{'selected': selectedItem === item.fullPath}" | |||
:title="item.entryName" | |||
@click.stop="doLoadDirContent" | |||
@click.middle.stop="doLoadFileContent" |
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.
It doesn't seem right. Here it is doLoadDirContent
, not doLoadFileContent
. And does it really work here?
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.
9c4a8e2. Yes it works here, it doesn't matter if the target is a file or directory
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" |
If you'd like to support "middle click", the ideal approach can be like this:
|
I think we should just render a native 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 only |
I see, maybe ideally it could be like this:
|
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 Maybe |
When clicking a file in the repo view file tree with the middle mouse button, the file will be now opened in a new tab.
file-tree-mouse-click.mp4