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
Этот коммит содержится в:
Paweł Pohl
2024-07-11 17:13:01 +02:00
коммит произвёл GitHub
родитель e8b4892877
Коммит 43b70e287a
2 изменённых файлов: 79 добавлений и 54 удалений

Просмотреть файл

@@ -37,13 +37,17 @@ exports[`SidebarList should match snapshot 1`] = `
onClick={[Function]} onClick={[Function]}
show={false} show={false}
/> />
<div
onPointerLeave={[Function]}
onPointerOver={[Function]}
>
<Scrollbars <Scrollbars
autoHeight={false} autoHeight={false}
autoHeightMax={200} autoHeightMax={200}
autoHeightMin={0} autoHeightMin={0}
autoHide={true} autoHide={true}
autoHideDuration={500} autoHideDuration={200}
autoHideTimeout={500} autoHideTimeout={1000}
hideTracksWhenNotNeeded={false} hideTracksWhenNotNeeded={false}
onScroll={[Function]} onScroll={[Function]}
renderThumbHorizontal={[Function]} renderThumbHorizontal={[Function]}
@@ -82,6 +86,7 @@ exports[`SidebarList should match snapshot 1`] = `
</DragDropContext> </DragDropContext>
</Scrollbars> </Scrollbars>
</div> </div>
</div>
</Fragment> </Fragment>
`; `;

Просмотреть файл

@@ -108,6 +108,7 @@ type Props = {
type State = { type State = {
showTopUnread: boolean; showTopUnread: boolean;
showBottomUnread: boolean; showBottomUnread: boolean;
autoHide: boolean;
}; };
// scrollMargin is the margin at the edge of the channel list that we leave when scrolling to a channel. // 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<Props, State> {
scrollbar: React.RefObject<Scrollbars>; scrollbar: React.RefObject<Scrollbars>;
animate: SpringSystem; animate: SpringSystem;
scrollAnimation: Spring; scrollAnimation: Spring;
channelsListScrollTimeout: NodeJS.Timeout | null = null;
constructor(props: Props) { constructor(props: Props) {
super(props); super(props);
@@ -133,6 +135,7 @@ export default class SidebarList extends React.PureComponent<Props, State> {
this.state = { this.state = {
showTopUnread: false, showTopUnread: false,
showBottomUnread: false, showBottomUnread: false,
autoHide: true,
}; };
this.scrollbar = React.createRef(); this.scrollbar = React.createRef();
@@ -462,6 +465,20 @@ export default class SidebarList extends React.PureComponent<Props, State> {
this.props.actions.stopDragging(); 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() { render() {
const {categories} = this.props; const {categories} = this.props;
@@ -562,11 +579,13 @@ export default class SidebarList extends React.PureComponent<Props, State> {
extraClass='nav-pills__unread-indicator-bottom' extraClass='nav-pills__unread-indicator-bottom'
content={below} content={below}
/> />
<div
onPointerLeave={this.hideChannelListScrollbar}
onPointerOver={this.showChannelListScrollbar}
>
<Scrollbars <Scrollbars
ref={this.scrollbar} ref={this.scrollbar}
autoHide={true} autoHide={this.state.autoHide}
autoHideTimeout={500}
autoHideDuration={500}
renderThumbHorizontal={renderThumbHorizontal} renderThumbHorizontal={renderThumbHorizontal}
renderThumbVertical={renderThumbVertical} renderThumbVertical={renderThumbVertical}
renderTrackVertical={renderTrackVertical} renderTrackVertical={renderTrackVertical}
@@ -577,6 +596,7 @@ export default class SidebarList extends React.PureComponent<Props, State> {
{channelList} {channelList}
</Scrollbars> </Scrollbars>
</div> </div>
</div>
</> </>
); );
} }