[MM-11258] Clear jumpTo focus on drawerClose (#1944)
* Clear jumpTo focus on drawerClose * Fix conditional if for clearSearch
This commit is contained in:
parent
154def4af8
commit
e45a3a0bb9
3 changed files with 21 additions and 7 deletions
|
|
@ -29,6 +29,7 @@ export default class ChannelsList extends PureComponent {
|
|||
onSelectChannel: PropTypes.func.isRequired,
|
||||
onShowTeams: PropTypes.func.isRequired,
|
||||
theme: PropTypes.object.isRequired,
|
||||
drawerOpened: PropTypes.bool,
|
||||
};
|
||||
|
||||
static contextTypes = {
|
||||
|
|
@ -48,6 +49,12 @@ export default class ChannelsList extends PureComponent {
|
|||
});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (!nextProps.drawerOpened && this.props.drawerOpened) {
|
||||
this.cancelSearch();
|
||||
}
|
||||
}
|
||||
|
||||
onSelectChannel = (channel, currentChannelId) => {
|
||||
if (this.refs.search_bar) {
|
||||
this.refs.search_bar.cancel();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ export default class DrawerSwiper extends Component {
|
|||
openDrawerOffset: PropTypes.number,
|
||||
showTeams: PropTypes.bool.isRequired,
|
||||
theme: PropTypes.object.isRequired,
|
||||
drawerOpened: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
|
@ -29,7 +30,8 @@ export default class DrawerSwiper extends Component {
|
|||
return nextProps.deviceWidth !== deviceWidth ||
|
||||
nextProps.showTeams !== showTeams ||
|
||||
nextProps.openDrawerOffset !== openDrawerOffset ||
|
||||
nextProps.theme !== theme;
|
||||
nextProps.theme !== theme ||
|
||||
nextProps.drawerOpened !== this.props.drawerOpened;
|
||||
}
|
||||
|
||||
runOnLayout = (shouldRun = true) => {
|
||||
|
|
|
|||
|
|
@ -59,12 +59,11 @@ export default class ChannelSidebar extends Component {
|
|||
openDrawerOffset = DRAWER_LANDSCAPE_OFFSET;
|
||||
}
|
||||
|
||||
this.drawerOpened = false;
|
||||
|
||||
this.state = {
|
||||
show: false,
|
||||
lockMode: 'unlocked',
|
||||
openDrawerOffset,
|
||||
drawerOpened: false,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +112,7 @@ export default class ChannelSidebar extends Component {
|
|||
}
|
||||
|
||||
handleAndroidBack = () => {
|
||||
if (this.drawerOpened && this.refs.drawer) {
|
||||
if (this.state.drawerOpened && this.refs.drawer) {
|
||||
this.refs.drawer.closeDrawer();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -126,7 +125,7 @@ export default class ChannelSidebar extends Component {
|
|||
};
|
||||
|
||||
closeChannelDrawer = () => {
|
||||
if (this.drawerOpened && this.refs.drawer) {
|
||||
if (this.state.drawerOpened && this.refs.drawer) {
|
||||
this.refs.drawer.closeDrawer();
|
||||
}
|
||||
};
|
||||
|
|
@ -136,12 +135,16 @@ export default class ChannelSidebar extends Component {
|
|||
};
|
||||
|
||||
handleDrawerClose = () => {
|
||||
this.drawerOpened = false;
|
||||
this.setState({
|
||||
drawerOpened: false,
|
||||
});
|
||||
this.resetDrawer();
|
||||
};
|
||||
|
||||
handleDrawerOpen = () => {
|
||||
this.drawerOpened = true;
|
||||
this.setState({
|
||||
drawerOpened: true,
|
||||
});
|
||||
|
||||
if (this.state.openDrawerOffset !== 0) {
|
||||
Keyboard.dismiss();
|
||||
|
|
@ -320,6 +323,7 @@ export default class ChannelSidebar extends Component {
|
|||
onSearchStart={this.onSearchStart}
|
||||
onSearchEnds={this.onSearchEnds}
|
||||
theme={theme}
|
||||
drawerOpened={this.state.drawerOpened}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
|
@ -335,6 +339,7 @@ export default class ChannelSidebar extends Component {
|
|||
onPageSelected={this.onPageSelected}
|
||||
openDrawerOffset={openDrawerOffset}
|
||||
showTeams={showTeams}
|
||||
drawerOpened={this.state.drawerOpened}
|
||||
>
|
||||
{lists}
|
||||
</DrawerSwiper>
|
||||
|
|
|
|||
Loading…
Reference in a new issue