javascript - Mouse scroll event Is not working for react select inside react scrollbar - Stack Overflow

I am using two packages:react-selectreactScrollbarI am using react scroller for smooth scrolling in my

I am using two packages:

  1. react-select
  2. reactScrollbar

I am using react scroller for smooth scrolling in my project. Inside the react scroller I am using react-select for smooth drop down.

Issue: Whenever I scroll for my react select dropdown. The parent scroll event also get fired and react-select closed it's dropdown. Due to that I am unable to select the value form dropdown.

I am using two packages:

  1. react-select
  2. reactScrollbar

I am using react scroller for smooth scrolling in my project. Inside the react scroller I am using react-select for smooth drop down.

Issue: Whenever I scroll for my react select dropdown. The parent scroll event also get fired and react-select closed it's dropdown. Due to that I am unable to select the value form dropdown.

Share Improve this question edited Dec 9, 2020 at 15:27 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Nov 22, 2017 at 13:34 Pankaj JatavPankaj Jatav 2,1842 gold badges15 silver badges22 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

My onWheel was scrolling the parent react-scrollbar scroll, so i added onWheel handler as follows on parent div of react select. Hope this helps

onWheel=(e)=>{
 e.stopPropagation();
}

<div onWheel={this.onWheel}
 <Select ../>
</div>

you can add menuPortalTarget={document.body} inside select tag.Like,

<select
...
menuPortalTarget={document.body}/>

It will attach your select ponent with document.body and dropdown won't be closed during scrolling.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745405411a4626290.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信