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

[FIX] Horizontal scrollbar not showing on tables #21852

Merged
merged 2 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/components/GenericTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const GenericTable = (
) : (
<>
<Box mi='neg-x24' pi='x24' flexShrink={1} flexGrow={1} ref={ref} overflow='hidden'>
<ScrollableContentWrapper>
<ScrollableContentWrapper overflowX>
<Table fixed={fixed} sticky>
{header && (
<Table.Head>
Expand Down
13 changes: 9 additions & 4 deletions client/components/ScrollableContentWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const styleDefault = {
};

export type CustomScrollbarsProps = {
overflowX?: boolean;
style?: CSSProperties;
children?: ReactNode;
onScroll?: (values: ScrollValues) => void;
Expand All @@ -26,7 +27,7 @@ export type CustomScrollbarsProps = {
};

const ScrollableContentWrapper = forwardRef<HTMLElement, CustomScrollbarsProps>(
function WrappedComponent({ children, style, onScroll, renderView }, ref) {
function WrappedComponent({ children, style, onScroll, overflowX, renderView }, ref) {
const scrollbarsStyle = useMemo(() => ({ ...style, ...styleDefault }), [
style,
]) as CSSProperties;
Expand All @@ -39,9 +40,13 @@ const ScrollableContentWrapper = forwardRef<HTMLElement, CustomScrollbarsProps>(
style={scrollbarsStyle}
onScrollFrame={onScroll}
renderView={renderView}
renderTrackHorizontal={(props): ReactElement => (
<div {...props} className='track-horizontal' style={{ display: 'none' }} />
)}
renderTrackHorizontal={
overflowX
? undefined
: (props): ReactElement => (
<div {...props} className='track-horizontal' style={{ display: 'none' }} />
)
}
renderThumbVertical={({ style, ...props }): JSX.Element => (
<div
{...props}
Expand Down