From 43b70e287a1a3621c1d05c90626d9145039c8fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pohl?= Date: Thu, 11 Jul 2024 17:13:01 +0200 Subject: [PATCH] MM-58351 Fix showing LHS scrollbar when moving mouse over on chrome and safari (#27160) * fixing scrollbar not showing when moving mouse over sidebar * making scrollbar hidden by default and keep shown when hover over channel list * updating sidebar_list snapshot --- .../__snapshots__/sidebar_list.test.tsx.snap | 87 ++++++++++--------- .../sidebar/sidebar_list/sidebar_list.tsx | 46 +++++++--- 2 files changed, 79 insertions(+), 54 deletions(-) diff --git a/webapp/channels/src/components/sidebar/sidebar_list/__snapshots__/sidebar_list.test.tsx.snap b/webapp/channels/src/components/sidebar/sidebar_list/__snapshots__/sidebar_list.test.tsx.snap index c50ea9f180..a2902b83a5 100644 --- a/webapp/channels/src/components/sidebar/sidebar_list/__snapshots__/sidebar_list.test.tsx.snap +++ b/webapp/channels/src/components/sidebar/sidebar_list/__snapshots__/sidebar_list.test.tsx.snap @@ -37,50 +37,55 @@ exports[`SidebarList should match snapshot 1`] = ` onClick={[Function]} show={false} /> - - - - - - - + + + + + + `; diff --git a/webapp/channels/src/components/sidebar/sidebar_list/sidebar_list.tsx b/webapp/channels/src/components/sidebar/sidebar_list/sidebar_list.tsx index 8b87eaf21a..dfd241efa3 100644 --- a/webapp/channels/src/components/sidebar/sidebar_list/sidebar_list.tsx +++ b/webapp/channels/src/components/sidebar/sidebar_list/sidebar_list.tsx @@ -108,6 +108,7 @@ type Props = { type State = { showTopUnread: boolean; showBottomUnread: boolean; + autoHide: boolean; }; // scrollMargin is the margin at the edge of the channel list that we leave when scrolling to a channel. @@ -125,6 +126,7 @@ export default class SidebarList extends React.PureComponent { scrollbar: React.RefObject; animate: SpringSystem; scrollAnimation: Spring; + channelsListScrollTimeout: NodeJS.Timeout | null = null; constructor(props: Props) { super(props); @@ -133,6 +135,7 @@ export default class SidebarList extends React.PureComponent { this.state = { showTopUnread: false, showBottomUnread: false, + autoHide: true, }; this.scrollbar = React.createRef(); @@ -462,6 +465,20 @@ export default class SidebarList extends React.PureComponent { this.props.actions.stopDragging(); }; + showChannelListScrollbar = () => { + if (this.channelsListScrollTimeout !== null) { + clearTimeout(this.channelsListScrollTimeout); + } + + this.setState({autoHide: false}); + }; + + hideChannelListScrollbar = () => { + this.channelsListScrollTimeout = setTimeout(() => { + this.setState({autoHide: true}); + }, 300); + }; + render() { const {categories} = this.props; @@ -562,20 +579,23 @@ export default class SidebarList extends React.PureComponent { extraClass='nav-pills__unread-indicator-bottom' content={below} /> - - {channelList} - + + {channelList} + + );