Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LeftNav doesn't play with iOS fullscreen mode #366

Closed
0x80 opened this issue Feb 25, 2015 · 4 comments · Fixed by #751
Closed

LeftNav doesn't play with iOS fullscreen mode #366

0x80 opened this issue Feb 25, 2015 · 4 comments · Fixed by #751
Labels
component: menu This is the name of the generic UI component, not the React module!

Comments

@0x80
Copy link

0x80 commented Feb 25, 2015

<meta name="apple-mobile-web-app-capable" content="yes">

This meta tag would allow iOS to display the app in fullscreen after using the "add to homescreen" feature in Safari. I found that by doing this I can't use the LeftNav component anymore, because it closes immediately after opening. I'm not able to hit any or the menu links.

@notduncansmith
Copy link

Reproduced this in Phonegap. It looks like it's the onTouchTap function: I can't reproduce the behavior if I use onClick instead.

My code for reference:

menuItems = [
  {route: '/foo', text: 'Foo'}
  {route: '/bar', text: 'Bar'}
]

App = React.createClass
  toggleMenu: ->
    @refs.nav.toggle()

  closeIfOpen: ->
    if @refs.nav.state.open
      @refs.nav.close()

  render: ->
    div {onTouchTap: @closeIfOpen},
      (UI.LeftNav {menuItems, docked: false, ref: 'nav'}),
      (UI.RaisedButton {label: 'Default', onTouchTap: @toggleMenu})

@notduncansmith
Copy link

Okay, well I figured out my problem.

So, I had added the closeIfOpen method so that the user could click anywhere to close the menu. Only thing is, I forgot to call e.preventDefault(). This meant the event was bubbling up to the main div, closing it instantly.

@0x80 if you have something like that in your code, maybe that's the problem.

@0x80
Copy link
Author

0x80 commented Mar 11, 2015

I have no idea what changed in my app, but I can't reproduce it anymore. The LeftNav seems to be working ok for me now.

@pomerantsev
Copy link
Contributor

I am able to consistently reproduce this problem, both in a webview using Cordova, and using the "Add to Home Screen" feature.
Here's the full reproduction code (which is very similar to @notduncansmith's, but without the closeIfOpen bit):

let React = require('react'),
    MUI = require('material-ui');

require('react-tap-event-plugin')();

let App = React.createClass({

  render () {
    let menuItems = [{ text: 'Menu item' }];

    return (
      <div>
        <MUI.LeftNav ref="leftNav"
                     menuItems={menuItems}
                     docked={false} />
        <div onTouchTap={this.onMenuToggleTouchTap}>
          Toggle menu
        </div>
      </div>
    );
  },

  onMenuToggleTouchTap () {
    this.refs.leftNav.toggle();
  }

});

React.render(<App />, document.body);

The problem is that a menu item reacts to a click event which happens after the nav is opened.
Not sure why it doesn't happen in standard browser mode in iOS though (not full-screen).
I will submit a PR fixing this shortly.

pomerantsev added a commit to pomerantsev/material-ui that referenced this issue Apr 25, 2015
pomerantsev added a commit to pomerantsev/material-ui that referenced this issue Apr 25, 2015
pomerantsev added a commit to pomerantsev/material-ui that referenced this issue Apr 25, 2015
pomerantsev added a commit to pomerantsev/material-ui that referenced this issue Jun 4, 2015
Fixes mui#366.

The problem is that the click event is fired *after* left-nav opens.
We're safe though if we just replace it with onTouchTap.
@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 25, 2022
@zannager zannager added component: menu This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module!
Projects
None yet
5 participants