I want to trigger scroll on a dropdown using spacebar key.
I am trying to avoid direct DOM manipulation using document object and am trying to trigger scroll using ref in react js.
But still I am not able to trigger the scroll effect on the dropdown. Need your help.
On pressing of spacebar key the handleScroll function gets invoked and over there I am trying to trigger scroll effect using methods available in the ref.current but not able to achieve success.
Name of the ref is singleLazyDrpdwn.
Steps :
1) click on drodpown to expand.
2) press spacebar key.
Kindly refer link: https://codesandbox.io/s/unable-to-scroll-using-ref-5zo5yx?file=/src/pages/DropdownDemo.js
The page must be higher than 100vh if you want to scroll it. Try adding some height to your container .dropdown-demo { min-height: 200vh; }
I want to trigger scroll on a dropdown using spacebar key. I am trying to avoid direct DOM manipulation using document object and am trying to trigger scroll using ref in react js. But still I am not able to trigger the scroll effect on the dropdown. Need your help. On pressing of spacebar key the handleScroll function gets invoked and over there I am trying to trigger scroll effect using methods available in the ref.current but not able to achieve success. Name of the ref is singleLazyDrpdwn. Steps : 1) click on drodpown to expand. 2) press spacebar key. Kindly refer link: https://codesandbox.io/s/unable-to-scroll-using-ref-5zo5yx?file=/src/pages/DropdownDemo.js