How to make Context Menu overflow scrollable in React
04 Sep 20264 minutes to read
Overflow Scrollable React Context Menu can be achieved by restricting the height of the ul element.
In the following example, the height of the React Context Menu popup list (ul) is restricted to 150px and the overflow property is set to auto, so a scrollbar appears when the items overflow the restricted height.
import { enableRipple } from '@syncfusion/ej2-base';
import { ContextMenuComponent } from '@syncfusion/ej2-react-navigations';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
let menuItems = [
{ text: 'ABS' },
{ text: 'ACOS' },
{ text: 'ACOSH' },
{ text: 'ACOT' },
{ text: 'ACOTH' },
{ text: 'AGGREGATE' },
{ text: 'COS' },
{ text: 'COSH' },
{ text: 'COT' },
{ text: 'COTH' }
];
return (<div className="container">
<div id='target'>Right click / Touch hold to open the ContextMenu</div>
<ContextMenuComponent id='contextmenu' target='#target' cssClass='e-custom' items={menuItems}/>
</div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('element'));import { enableRipple } from '@syncfusion/ej2-base';
import { ContextMenuComponent, MenuItemModel } from '@syncfusion/ej2-react-navigations';
import * as React from 'react';
import * as ReactDom from 'react-dom';
enableRipple(true);
function App() {
let menuItems: MenuItemModel[] = [
{ text: 'ABS' },
{ text: 'ACOS' },
{ text: 'ACOSH' },
{ text: 'ACOT' },
{ text: 'ACOTH' },
{ text: 'AGGREGATE' },
{ text: 'COS' },
{ text: 'COSH' },
{ text: 'COT' },
{ text: 'COTH' }
];
return (
<div className="container">
<div id='target'>Right click / Touch hold to open the ContextMenu</div>
<ContextMenuComponent id='contextmenu' target='#target' cssClass='e-custom' items={menuItems} />
</div>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('element'));