Compatibility issue with react-custom-scrollbars
See original GitHub issueTrying to use react-custom-scrollbars
inside a custom MenuList
component makes the keyboard navigation of react-select
break.
Example:
// CustomMenuList.tsx
import React from "react";
import { components } from "react-select";
import { Scrollbars } from "react-custom-scrollbars";
import styled from "styled-components";
export const MenuList = (props: any) => {
return (
<components.MenuList {...props}>
<div style={{ height: 200 }}>
<Scrollbars>
{props.children}
</Scrollbars>
</div>
</components.MenuList>
);
};
// App.tsx
<Select
components={{ MenuList }}
captureMenuScroll={false} // custom scrollbar doesn't scroll if this is true
/>
With the above code, the dropdown list no longer scrolls to the focused option when trying to navigate using the keyboard arrow keys. However, if we remove the <Scrollbars>
component, then the keyboard navigation works as expected and the menu starts scrolling as we press the down arrow key repeatedly.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
react-custom-scrollbars-2
Start using react-custom-scrollbars-2 in your project by running `npm i react-custom-scrollbars-2`. There are 54 other projects in the npm ...
Read more >IE compatability issues in react app. scroll bar problems
i am building a react app for my client and i am having some compatibility issues with IE. My side bar works fine...
Read more >react-custom-scrollbars
Is there any way of disabling the custom scrollbar when the div doesn't need a scrollbar? Or at least any workaround for this...
Read more >react-custom-scrollbars versions and peer dependencies
Online Peer dependency version tool to search for compatible versions of related NPM packages.
Read more >react-scrollbars-custom | Yarn - Package Manager
owner xobotyi157.4kMIT4.1.1TS vulns 0 vulnerabilities. The best React custom scrollbars component. customizable, scrollbars, scroll, scrollbar ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cseas @kabdelkareem
The
Select
component requires aref
to the scrollable container of the options list to scroll to the focused option. TheMenuList
component receives for this theinnerRef
prop.But we can´t just simply set the
ref
prop on theScrollbars
component, because this would be a reference to the component, not the actual DOM element.For this we would have to do as follows:
At first we need the reference to the
Scrollbars
component. It contains a reference to the needed DOM element. Then as soon as the reference exists we set the reference to the scrolling DOM element as ourinnerRef
reference.@cseas I have tried it and it is working. thanks @Rall3n