diff --git a/apps/meteor/client/components/CustomScrollbars/CustomScrollbars.tsx b/apps/meteor/client/components/CustomScrollbars/CustomScrollbars.tsx index d443639794f15..a3f60470fa89c 100644 --- a/apps/meteor/client/components/CustomScrollbars/CustomScrollbars.tsx +++ b/apps/meteor/client/components/CustomScrollbars/CustomScrollbars.tsx @@ -2,7 +2,7 @@ import { Palette } from '@rocket.chat/fuselage'; import type { ScrollValues } from 'rc-scrollbars'; import { Scrollbars } from 'rc-scrollbars'; import type { MutableRefObject, CSSProperties, ReactNode } from 'react'; -import React, { memo, forwardRef, useCallback, useMemo } from 'react'; +import React, { memo, forwardRef, useCallback, useMemo, useEffect } from 'react'; export type CustomScrollbarsProps = { overflowX?: boolean; @@ -16,10 +16,22 @@ export type CustomScrollbarsProps = { const styleDefault: CSSProperties = { flexGrow: 1, - overflowY: 'hidden', + willChange: 'transform', + overflowY: 'hidden' }; -const CustomScrollbars = forwardRef(function CustomScrollbars( +// Styles to hide the default scrollbar +const hideScrollbarStyle = ` + [dir="rtl"] { + overflow: hidden; + } + + [dir="rtl"] ::-webkit-scrollbar { + display: none; + } +`; + +const CustomScrollbars = forwardRef(function CustomScrollbars( { children, style, onScroll, overflowX, renderView, ...props }, ref, ) { @@ -32,13 +44,24 @@ const CustomScrollbars = forwardRef(function ref(scrollbarRef.view ?? null); return; } - - (ref as MutableRefObject).current = scrollbarRef.view; + (ref as MutableRefObject).current = scrollbarRef.view; } }, [ref], ); + // Dynamically using the hide scrollbar style to hide default scrollbar + + useEffect(() => { + const styleElement = document.createElement('style'); + styleElement.innerHTML = hideScrollbarStyle; + document.head.appendChild(styleElement); + + return () => { + document.head.removeChild(styleElement); + }; + }, []); + return ( (function style={scrollbarsStyle} onScrollFrame={onScroll} renderView={renderView} - renderTrackHorizontal={overflowX ? undefined : (props) =>
} + renderTrackHorizontal={overflowX ? undefined : (trackProps) =>
} renderThumbVertical={({ style, ...props }) => (
)}