Skip to content

feat(components): [virtual-list] support horizontal scrolling with mouse wheel on Windows/ubuntu#22168

Merged
Dsaquel merged 9 commits into
element-plus:devfrom
keeplearning66:feat/useWheel
Dec 28, 2025
Merged

feat(components): [virtual-list] support horizontal scrolling with mouse wheel on Windows/ubuntu#22168
Dsaquel merged 9 commits into
element-plus:devfrom
keeplearning66:feat/useWheel

Conversation

@keeplearning66
Copy link
Copy Markdown
Member

@keeplearning66 keeplearning66 commented Sep 15, 2025

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.
image

resolve #22370

Currently, when there are many tabs in the horizontal direction, users can only scroll through the tabs using a touchpad, as the mouse wheel cannot be used for scrolling since deltaX is always 0(On my computer, holding the Shift key doesn't enable horizontal scrolling of the tabs either).
If users are accustomed to using a mouse while browsing the web, they may prefer scrolling with the mouse wheel. Therefore, directly supporting horizontal scrolling with the mouse wheel could provide a better experience.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 15, 2025

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Sep 15, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/element-plus/element-plus@22168

commit: f3007c4

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Sep 15, 2025

🧪 Playground Preview: https://element-plus.run/?pr=22168
Please comment the example via this playground if needed.

@rzzf
Copy link
Copy Markdown
Member

rzzf commented Sep 15, 2025

Currently, when there are many tabs in the horizontal direction, users can only scroll through the tabs using a touchpad, as the mouse wheel cannot be used for scrolling since deltaX is always 0

#22024 includes support for mouse scrolling.

Note that you should hold down the shift key when scrolling horizontally, This is consistent with native scrolling.

Demo

@rzzf
Copy link
Copy Markdown
Member

rzzf commented Sep 15, 2025

If horizontal Tabs need to support vertical scrolling, I suggest implementing it inside the Tabs component to avoid breaking the behavior of the virtual-list.

But we can wait for the members’ opinions first.😃

@keeplearning66
Copy link
Copy Markdown
Member Author

keeplearning66 commented Sep 16, 2025

Thank you for the reminder. On my computer, holding the Shift key doesn't enable horizontal scrolling of the tabs either (though swiping on the touchpad works).
I also compared it with several other component libraries, which support horizontal scrolling directly using the mouse wheel. That's why I created this PR. 😃

@keeplearning66 keeplearning66 changed the title feat(components): [tabs] horizontal mouse wheel scrolling is supported feat(components): [tabs] directly support horizontal scrolling with the mouse wheel Sep 17, 2025
@Dsaquel
Copy link
Copy Markdown
Member

Dsaquel commented Sep 29, 2025

On my computer, holding the Shift key doesn't enable horizontal scrolling of the tabs either (though swiping on the touchpad works).

Me too, shift + scroll doesn't work.

I also compared it with several other component libraries, which support horizontal scrolling directly using the mouse wheel. That's why I created this PR. 😃

Honestly I'm little bit surprised other libraries like ant design handle this behavior. It feels unnatural to allow this type of scroll.

That said i don't really have an opinion on this.

Comment thread packages/components/virtual-list/src/hooks/use-wheel.ts Outdated
Copy link
Copy Markdown
Member

@Dsaquel Dsaquel left a comment

Choose a reason for hiding this comment

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

LGTM

@keeplearning66
Copy link
Copy Markdown
Member Author

keeplearning66 commented Oct 6, 2025

@Dsaquel Hello, I have found a problem. 🤔

If we modify it directly like this: layout: computed(() => 'vertical'), it will affect the horizontal scroll behavior on the touchpad. When swiping left and right, horizontal scrolling will not work because the change is in deltaX, not deltaY.

So we might still need the following code to handle this issue.
image

I've thought of two ways to handle it.

  1. Declare handleWheel in tab-nav.tsx, including the code above. This will not affect useWheel.
  2. Add a property in useWheel, such as isTabs, with a default value of false. The handling logic from the above code will only be applied when it is set to true.

I'm not sure which approach is more suitable. Do you have any thoughts on this? 👀 👀

@Dsaquel
Copy link
Copy Markdown
Member

Dsaquel commented Oct 6, 2025

Nice catch, i need to hold and understand why we both cannot scroll using shift key.
Taking a step back, maybe there is a way to allow us scroll with shift key.

@rzzf
Copy link
Copy Markdown
Member

rzzf commented Oct 12, 2025

Nice catch, i need to hold and understand why we both cannot scroll using shift key. Taking a step back, maybe there is a way to allow us scroll with shift key.

This appears to be caused by differences between systems or browsers.

This file might help address the issue: https://github.com/facebookarchive/fixed-data-table/blob/master/src/vendor_upstream/dom/normalizeWheel.js

P.S: The mousewheel directive also depends on it.

import normalizeWheel from 'normalize-wheel-es'

@keeplearning66
Copy link
Copy Markdown
Member Author

keeplearning66 commented Oct 15, 2025

Thank you, but the issue is still not resolved after I used normalize-wheel-es. 🤔

Maybe some of the code in tab-nav.tsx is causing this issue, because I noticed that I can use shift + scroll to horizontally scroll in Table(table-with-fixed-column), but I haven't figured out a better solution yet. 😢

@rzzf
Copy link
Copy Markdown
Member

rzzf commented Oct 17, 2025

Maybe some of the code in tab-nav.tsx is causing this issue, because I noticed that I can use shift + scroll to horizontally scroll in Table(table-with-fixed-column), but I haven't figured out a better solution yet. 😢

Can we try using the v-mousewheel directive like we do with the Table component? Sorry, I don’t have a Windows device, so I’m unable to test this myself.

v-mousewheel="handleHeaderFooterMousewheel"

@keeplearning66
Copy link
Copy Markdown
Member Author

Thank you, but this seems unrelated to v-mousewheel, because even after I removed v-mousewheel from table.vue, I can still use shift + scroll to scroll horizontally. You can take a look at the comment below. 👀 👀

@keeplearning66
Copy link
Copy Markdown
Member Author

keeplearning66 commented Oct 20, 2025

I found a piece of code in use-grid-wheel.ts, which should be handling the horizontal scrolling situation in Windows.

// Special case for windows machine with shift key + wheel scrolling
if (e.shiftKey && y !== 0) {
   x = y
   y = 0
}

So I added this logic to use-wheel.ts. Do you think this is appropriate? 🤔

@keeplearning66 keeplearning66 changed the title feat(components): [tabs] directly support horizontal scrolling with the mouse wheel feat(components): [tabs] support horizontal scrolling on Windows Oct 20, 2025
Comment thread packages/components/virtual-list/src/hooks/use-wheel.ts
@keeplearning66 keeplearning66 changed the title feat(components): [tabs] support horizontal scrolling on Windows feat(components): [tabs] support horizontal scrolling with mouse wheel on Windows Nov 30, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 30, 2025

Hello, @keeplearning66, your PR title does not meet the standards, please refer to here.
你好,@keeplearning66,你的 PR 标题不符合规范,请参考这里

@github-actions github-actions Bot added the CommitMessage::Unqualified Unqualified commit message label Nov 30, 2025
@Dsaquel
Copy link
Copy Markdown
Member

Dsaquel commented Nov 30, 2025

Unfortunately, with my linux system (Ubuntu 24) using shift + scroll to scroll horizontally doesn't work in local or playground.

@rzzf
Copy link
Copy Markdown
Member

rzzf commented Dec 28, 2025

Unfortunately, with my linux system (Ubuntu 24) using shift + scroll to scroll horizontally doesn't work in local or playground.

On Firefox running in an Ubuntu 24 virtual machine, native scrolling doesn’t work for me, but it works correctly inside the Tabs component. Is there any configuration I need to adjust?

20251228-161323.mp4

@Dsaquel
Copy link
Copy Markdown
Member

Dsaquel commented Dec 28, 2025

On Firefox running in an Ubuntu 24 virtual machine, native scrolling doesn’t work for me, but it works correctly inside the Tabs component. Is there any configuration I need to adjust?

I'm in a different desktop but still using Ubuntu 24 and both works now... 😆.

@Dsaquel Dsaquel changed the title feat(components): [tabs] support horizontal scrolling with mouse wheel on Windows feat(components): [virtual-list] support horizontal scrolling with mouse wheel on Windows/ubuntu Dec 28, 2025
@Dsaquel Dsaquel merged commit 2355a19 into element-plus:dev Dec 28, 2025
16 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@keeplearning66 Thanks for your contribution! ❤️

@keeplearning66 keeplearning66 deleted the feat/useWheel branch December 29, 2025 00:45
@element-bot element-bot mentioned this pull request Jan 9, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Component] [tabs] Tabs cannot scroll when positioned on the top or bottom .

3 participants