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

How to set Left Nav props.docked desktop : true, mobile : false? #1633

Closed
borm opened this issue Sep 12, 2015 · 2 comments
Closed

How to set Left Nav props.docked desktop : true, mobile : false? #1633

borm opened this issue Sep 12, 2015 · 2 comments
Labels
support: question Community support but can be turned into an improvement

Comments

@borm
Copy link

borm commented Sep 12, 2015

Subj
I've tried change docked variable when component render

isDocked(){
    let docked = false;

    if (this.isDeviceSize(StyleResizable.statics.Sizes.MEDIUM) ||
      this.isDeviceSize(StyleResizable.statics.Sizes.LARGE)) {
      docked = true;
    }
    return docked;
  },

  render() {
    let header = (
      <div style={this.getStyles()} onTouchTap={this._onHeaderClick}>
        material ui
      </div>
    );
    this.docked = this.isDocked();
    return (
      <LeftNav
        ref="leftNav"
        docked={this.docked}
        isInitiallyOpen={false}
        header={header}
        menuItems={menuItems}
        selectedIndex={this._getSelectedIndex()}
        onChange={this._onLeftNavChange} />
    );
  },
@borm
Copy link
Author

borm commented Sep 13, 2015

I have only one solution

componentWillMount(){
    let setTabsState = function() {
      this.setState({isDocked: !(document.body.clientWidth <= 647)});
    }.bind(this);
    setTabsState();
    window.onresize = setTabsState;
  }

@CalebEverett
Copy link

I got this to work by adding a few lines to the _onWindowResize function in left-nav.js:

    if (this.props.docked) {
      this.open()
    }
    else {
      this.close()
    }

@mbrookes mbrookes added the support: question Community support but can be turned into an improvement label Mar 25, 2016
mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

3 participants