ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 416 forks source link

[Android] 'hardware menu key' press make Tab Bar disappeared #32

Closed sospartan closed 6 years ago

sospartan commented 8 years ago

I found this behavior when change android native code to disable dev menu. I block-commented the detect menu key part :

@Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        /*if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
            mReactInstanceManager.showDevOptionsDialog();
            return true;
        }*/
        return super.onKeyUp(keyCode, event);
    }

After rerun the app , hit the menu key twice , the TabBar is gone ... I can't figure out the reason.

Environment:

Javascript code:

'use strict';

import React,{AppRegistry,View,Text} from 'react-native';
import TabNavigator from 'react-native-tab-navigator';

var TabPage = React.createClass({
  propTypes:{
    text:React.PropTypes.number
  },
  render:function(){
    return (<View style={{flex:1,top:0,alignItems:'center',justifyContent:'center',backgroundColor:'grey'}}>
            <Text >{this.props.text}</Text>
      </View>);
  }
});

var App = React.createClass({
  getInitialState: function() {
    return {
      selectedTab: 'tab1',
    };
  },
  render:function(){
    return (
      <TabNavigator style={{flex:1,backgroundColor:'green'}}>
        <TabNavigator.Item
        selected={this.state.selectedTab === 'tab1'}
        onPress={() => this.setState({ selectedTab: 'tab1' })}
          title="tab1"

          >
          <TabPage text={1}/>
        </TabNavigator.Item>
        <TabNavigator.Item
        selected={this.state.selectedTab === 'tab2'}
        onPress={() => this.setState({ selectedTab: 'tab2' })}
        title="tab2"
          >
          <TabPage text={2}/>
        </TabNavigator.Item>
    </TabNavigator>
  );
  }
});

AppRegistry.registerComponent('Index', () => App);
ide commented 8 years ago

I am not sure what happened. Anyone else have an idea?

ptomasroos commented 6 years ago

Will close since this issue is more than a year, feel free to a open a new if this is still a issue.