diff --git a/app/components/sidebars/main/drawer_swipper/drawer_swiper.js b/app/components/sidebars/main/drawer_swipper/drawer_swiper.js index 8edee0e6f2..358a922045 100644 --- a/app/components/sidebars/main/drawer_swipper/drawer_swiper.js +++ b/app/components/sidebars/main/drawer_swipper/drawer_swiper.js @@ -52,6 +52,12 @@ export default class DrawerSwiper extends Component { } }; + scrollToInitial = () => { + if (this.swiperRef?.current) { + this.swiperRef.current.scrollToInitial(); + } + } + swiperPageSelected = (index) => { this.props.onPageSelected(index); }; diff --git a/app/components/sidebars/main/main_sidebar.js b/app/components/sidebars/main/main_sidebar.js index 0233f7a88c..8ea04b3914 100644 --- a/app/components/sidebars/main/main_sidebar.js +++ b/app/components/sidebars/main/main_sidebar.js @@ -338,6 +338,7 @@ export default class ChannelSidebar extends Component { if (this.drawerSwiper) { if (multipleTeams) { this.drawerSwiper.runOnLayout(); + this.drawerSwiper.scrollToInitial(); } else if (!openDrawerOffset) { this.drawerSwiper.scrollToStart(); } diff --git a/app/components/swiper.js b/app/components/swiper.js index 4764839fe8..6e69bc0a8b 100644 --- a/app/components/swiper.js +++ b/app/components/swiper.js @@ -107,6 +107,14 @@ export default class Swiper extends PureComponent { }); }; + scrollToInitial = () => { + setTimeout(() => { + if (this.scrollView) { + this.scrollView.scrollTo({x: this.props.width * this.props.initialPage, animated: false}); + } + }, 0); + }; + refScrollView = (view) => { this.scrollView = view; };