[MM-18550] Force drawer to open to channel menu when new teams are added (#3266)

This commit is contained in:
Devin Binnie 2019-09-18 09:22:55 -04:00 committed by GitHub
parent e9db272a9e
commit 0db54cd3c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -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);
};

View file

@ -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();
}

View file

@ -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;
};