Material-ui: [Tabs] Dynamic Tabs break indicator when selecting newest tab

Created on 24 Aug 2017  路  3Comments  路  Source: mui-org/material-ui

Problem description

When you add a new tab and select the tab in the same frame, the indicator is unable to retrieve meta data about the tab, because it hasn't been rendered yet.

Related to this line: https://github.com/callemall/material-ui/blob/v1.0.0-beta.5/src/Tabs/Tabs.js#L161

Steps to reproduce

https://codesandbox.io/s/4z17ol2jmw

Versions

  • Material-UI: v1.0.0-beta.5
  • React: 15.5.3
  • Browser: Firefox 55.0
Tabs enhancement good first issue

Most helpful comment

eventually this is a bit shortsighted, but wouldn't moving

componentWillReceiveProps(nextProps) {
    if (this.props.value !== nextProps.value) {
      this.updateIndicatorState(nextProps);
    }
  }

to componentDidUpdate do the trick?

componentDidUpdate(prevProps, prevState) {
    (...)
    f (this.props.value !== prevProps.value) {
      this.updateIndicatorState(this.props);
    }
  }

All 3 comments

Because this is in -beta.5, should I work on that version? Or should I verify the same thing is happening in the latest version of the beta branch, then attempt to fix it there?

@Seurimas are you working on this?

I'm not working on this. Also, swapping in -beta.7 for the sandbox still exhibits the issue: https://codesandbox.io/s/98p8lq9xjo

eventually this is a bit shortsighted, but wouldn't moving

componentWillReceiveProps(nextProps) {
    if (this.props.value !== nextProps.value) {
      this.updateIndicatorState(nextProps);
    }
  }

to componentDidUpdate do the trick?

componentDidUpdate(prevProps, prevState) {
    (...)
    f (this.props.value !== prevProps.value) {
      this.updateIndicatorState(this.props);
    }
  }
Was this page helpful?
0 / 5 - 0 ratings