Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to customize the hardcoded wrapper Component. #1995

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ensemblebd
Copy link

@ensemblebd ensemblebd commented Mar 25, 2023

Allow user to customize the hardcoded wrapper Component.
Without this, user has no control over the overflow wrapper, and thus cannot implement custom scroll systems, or drag systems, etc.

ie:

	...

	return (
		<MUIDataTable
			data={props.data.Entries}
			columns={columns}
			options={mui_table_options}
			components={{
				ReactiveWrapper: DragScrollable,
			}}
		/>
	);
}

const DragScrollable = (props) => {
	const classes = useStyles();
	const ref= React.useRef(null); 
	const { events } = useDraggable(ref); // https://www.npmjs.com/package/react-use-draggable-scroll

	const {style, className} = props; // these are fed from MuiDataTable

	return (
		<div 
			ref={ref} 
			{...events} 
			className={cx(classes.dragContainer, className, classes.scrollHide)} 
			style={{width: 'calc(100% - 9px)', height: 'calc(100% - 9px)', ...style}}
		/>
	);
};

For me this was of particular interest so as to implement https://www.npmjs.com/package/react-custom-scrollbars-2 and https://www.npmjs.com/package/react-use-draggable-scroll.
Now when I set tableBodyHeight, the browser default scroll isn't used, rather my own system.
But this could of course be used for any number of purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant