primitives icon indicating copy to clipboard operation
primitives copied to clipboard

[DropdownMenu] dropdown menu scrolls on hover

Open misha-erm opened this issue 3 years ago • 8 comments

Bug report

Current Behavior

When I hover last/first visible item in dropdown menu content it autoscrolls to some random element

https://user-images.githubusercontent.com/8783498/180736094-2052435d-9f1d-4ae8-aa4d-2096701515fc.mov

Expected behavior

DropdownMenu.Content should not scroll on item hover

Reproducible example

CodeSandbox Template

Suggested solution

Additional context

Keyboard navigation feels a bit awkward too. Seems like it tries to keep focused element in the center of the list and those jumps are bit weird

Seems to be reproducible on both versions 0.1.6 and 1.0.0

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-dropdown-menu 1.0.0
React n/a 16.14
Browser Brave Version 1.40.113 Chromium: 103.0.5060.114 (Official Build) (x86_64)
Assistive tech
Node n/a
npm/yarn
Operating System MacOs 12.4

misha-erm avatar Jul 25 '22 08:07 misha-erm

Hey @MikeYermolayev curious on your use case for an overflow scroll on the dropdown? unlike Select, dropdown menu doesn't have first class support for it.

andy-hook avatar Jul 27 '22 14:07 andy-hook

Right now I can imagine 3 cases where we use dropdowns and the list can get long enough:

  1. language selector in code editor block. Here it should be definitely replaced with Select, thank you. Somehow we missed existence of radix select component 😅
  2. 'Add block' dropdown menu. Currently it doesn't have a lot of blocks but it definitely will one day so we should restrict max-height for this one. For example Notion's 'add block' menu has a plenty of items image
  3. We have a concept of automations and custom actions/buttons, so the list of actions in that case can get long enough too image

misha-erm avatar Jul 27 '22 14:07 misha-erm

Thanks for that @MikeYermolayev, makes sense and sounds sensible. Looks like the main jank is related to browser scroll behaviour when focus is changing. We should look into how to improve this for dropdown as we have for select

andy-hook avatar Aug 10 '22 09:08 andy-hook

What if you use a radix scroll area instead?

clearly-outsane avatar Jan 25 '23 13:01 clearly-outsane

The sub menu scrolling with the trigger is also a problem IMO

hipstersmoothie avatar Mar 27 '23 19:03 hipstersmoothie

Just want to share one more case where I faced this problem again...

The issue becomes more critical when the dropdown is placed above the trigger because first interaction with the menu causes ui jumps

https://github.com/radix-ui/primitives/assets/8783498/9e0f541d-87b0-4ab5-8524-5cc7f86ba070

misha-erm avatar Sep 14 '23 14:09 misha-erm

Any progress on this bug? I am experiencing this as well and would love to know if a fix is planned.

nina-loet avatar Feb 01 '24 18:02 nina-loet

@nina-loet I've got a PR open which fixes it (https://github.com/radix-ui/primitives/pull/2451), but it looks like Radix haven't been reviewing incoming PRs lately.

cpmsmith avatar Feb 05 '24 16:02 cpmsmith

I am also experiencing some difficulties because of this current behaviour. Any progress? Would love to see a fix for this issue.

mjvandenberg avatar Mar 06 '24 14:03 mjvandenberg

We need this as well. Hopefully the fix PR can be reviewed soon!

pozdena avatar Mar 14 '24 13:03 pozdena