0

Material UI Tabs has stopped working... It must have been after an update as it's not working at all now. It could have been caused by the recent update to react-tap-event-plugin I made. Initially, I thought it was because of my tab indexing but it doesn't work with the a,b,c values too e.g. value='a', value='b', etc.

I have even tried it with a stripped out version as a clean new component like so:

//imports
//'use strict';
import * as React from 'react';
import { Button, PrimaryButton, IButtonProps } from 'office-ui-fabric-react';
//import styles from './Npmsharepoint2.module.scss';
//import styles from './AZ.module.scss';
import { IAZProps } from './IAZProps';
import { escape } from '@microsoft/sp-lodash-subset';
var striptags = require('striptags');
//Routing/networking
import {
  SPHttpClient,
  SPHttpClientResponse,
  ISPHttpClientOptions    
} from '@microsoft/sp-http';
import * as ReactDom from 'react-dom';
import { IListItem } from './IListItem';
//Icons
import RaisedButton from 'material-ui/RaisedButton';
import {MdCancel, 
    MdChat, MdCheck, 
    MdAddBox, 
    MdHourglassFull,
    MdDone, MdHome} from 'react-icons/lib/md'
import FaIconPack from 'react-icons/lib/fa'
import TiIconPack from 'react-icons/lib/ti'
import {Tabs, Tab} from 'material-ui/Tabs';

import {
  Table,
  TableBody,
  TableHeader,
  TableHeaderColumn,
  TableRow,
  TableRowColumn,
} from 'material-ui/Table';
import Image from 'material-ui-image';
//import { storiesOf, action } from '@kadira/storybook';

//Tried this:
// since the export is a function, this is the only actual correct way:
import injectTapEventPluginRequire = require("react-tap-event-plugin");

//And this too!!:
//import * as injectTapEventPluginExport from 'react-tap-event-plugin';
//const injectTapEventPlugin = (injectTapEventPluginExport as any).default;
injectTapEventPluginRequire();


import { IAZRedxFormControllerProps } from './IAZRedxFormControllerProps';
import { IAZRedxFormControllerState } from './IAZRedxFormControllerState';
import AZRedxForm from './AZRedxForm';
import AZRedxList from './AZRedxList';


const data = ['Alexandre', 'Thomas', 'Lucien']
const cardCompstyles = {
  headline: {
    fontSize: 24,
    paddingTop: 16,
    marginBottom: 12,
    fontWeight: 400,
  },
  slide: {
    padding: 10,
  },
  largeIcon: {
    width: 60,
    height: 60,
  },
};

// From https://github.com/oliviertassinari/react-swipeable-views
import SwipeableViews from 'react-swipeable-views';

const styles = {
  headline: {
    fontSize: 24,
    paddingTop: 16,
    marginBottom: 12,
    fontWeight: 400,
  },
  slide: {
    padding: 10,
  },
};

export interface CardCompTestState {
    slideIndex: number;
  }

  export interface IAZRedxFormControllerTestProps {
    title: string;
    description: string;
    listName: string;
    //pollService: IPollService;
  }

  export default class AZCardTest extends React.Component<IAZRedxFormControllerTestProps, CardCompTestState> {
    constructor(props: IAZRedxFormControllerTestProps) {
      super(props);
      this.state = {
        slideIndex: 0
      };
    }

  handleChange = (value) => {
    this.setState({
      slideIndex: value,
    });
  };

  render() {
    return (
      <div>
        <Tabs
          onChange={this.handleChange}
          value={this.state.slideIndex}
        >
          <Tab label="Tab One" value={0} />
          <Tab label="Tab Two" value={1} />
          <Tab label="Tab Three" value={2} />
        </Tabs>
        <SwipeableViews
          index={this.state.slideIndex}
          onChangeIndex={this.handleChange}
        >
          <div>
            <h2 style={styles.headline}>Tabs with slide effect</h2>
            Swipe to see the next slide.<br />
          </div>
          <div style={styles.slide}>
            slide n°2
          </div>
          <div style={styles.slide}>
            slide n°3
          </div>
        </SwipeableViews>
      </div>
    );
  }
}

My versionings:

{
  "name": "npmsharepoint",
  "version": "0.0.1",
  "private": true,
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "build": "browserify -t [ babelify --presets [ react ] ] src/app/scripts/main.js -o src/scripts/app.js",
    "clean": "gulp clean",
    "test": "gulp test"
  },
  "dependencies": {
    "@microsoft/sp-core-library": "~1.1.0",
    "@microsoft/sp-lodash-subset": "~1.1.0",
    "@microsoft/sp-office-ui-fabric-core": "~1.4.0-0",
    "@microsoft/sp-webpart-base": "~1.1.0",
    "@types/jquery": "^2.0.48",
    "@types/jqueryui": "https://registry.npmjs.org/@types/jqueryui/-/jqueryui-1.11.37.tgz",
    "@types/react": "0.14.46",
    "@types/react-addons-shallow-compare": "0.14.17",
    "@types/react-addons-test-utils": "0.14.15",
    "@types/react-addons-update": "0.14.14",
    "@types/react-dom": "0.14.18",
    "@types/webpack-env": ">=1.12.1 <1.14.0",
    "babel-preset-react": "^6.24.1",
    "babelify": "^8.0.0",
    "bootstrap": "^4.0.0-beta.2",
    "browser-router": "^0.2.0",
    "jquery": "^2.2.4",
    "jqueryui": "https://registry.npmjs.org/jqueryui/-/jqueryui-1.11.1.tgz",
    "material-ui-image": "^2.1.1",
    "prop-types": "^15.6.0",
    "react": "15.4.2",
    "react-autosuggest": "^9.3.2",
    "react-bootstrap": "^0.31.5",
    "react-bootstrap-table": "^4.3.1",
    "material-ui": "^0.16.0",
    "react-dom": "15.4.2",
    "react-icons": "^2.2.7",
    "react-responsive-modal": "^2.0.0",
    "react-select": "^1.1.0",
    "react-swipe-card": "^0.1.4",
    "react-swipe-views": "0.0.12",
    "react-swipeable-views": "^0.12.12",
    "reactstrap": "^5.0.0-alpha.4",
    "sp-pnp-js": "^3.0.3"
  },
  "devDependencies": {
    "@microsoft/sp-build-web": "~1.1.0",
    "@microsoft/sp-module-interfaces": "~1.1.0",
    "@microsoft/sp-webpart-workbench": "~1.1.0",
    "style-loader": "^0.18.2",
    "css-loader": "^0.28.6",
    "@types/chai": ">=3.4.34 <3.6.0",
    "@types/material-ui": "^0.20.0",
    "@types/mocha": ">=2.2.33 <2.6.0",
    "@types/react-tap-event-plugin": "0.0.30",
    "ajv": "~5.2.2",
    "gulp": "~3.9.1"
  }
}
Roy Scheffers
  • 3,832
  • 11
  • 31
  • 36
KidKode
  • 179
  • 3
  • 11
  • Are there any console error messages in the dev tools? – Nick Feb 05 '18 at 14:20
  • None at all when I exclude the ref to `injectTapEventPlugin` but slide or tabs still not working. Infact none of the examples from Materieal-UI examples work. It could be a Dependency issue (i.e. versions etc) more than indexing of tabs I think but been at it all morning...still no luck. – KidKode Feb 05 '18 at 14:25
  • Referencing injectTapEventPlugin gives an error in Console: cannot find plugin `react-tap-event-plugin`. – KidKode Feb 05 '18 at 14:26
  • did you check whether you are maintaining the state correctly? – Vikas Yadav Feb 05 '18 at 14:28
  • State appears to be correct too...unless I have an obvious mistake...which I can't see... :-\ – KidKode Feb 05 '18 at 15:24
  • Changing my initial state does change the tab position...so will look here as this could be the culprit. – KidKode Feb 05 '18 at 15:44
  • One thing to note is the examples without State don't work too. – KidKode Feb 05 '18 at 16:05
  • 1
    Found the issue @VikasYadav it was duplication of root modules and files. See my other question https://stackoverflow.com/questions/48642248/is-shrinkwrap-preventing-me-from-updating-react-and-react-dom/48645855#48645855 – KidKode Feb 06 '18 at 14:58

1 Answers1

0

Based off of your latest comments it seems like your handleChange that's doing setState is the culprit.

Based off of the latest docs for material-ui you could try:

handleChange = (event, value) => {
  this.setState({
    slideIndex: value,
  });
};

Looks like you might be trying to use the entire event object instead of the value. (you could also just use the event but do this.setState({slideIndex: event.target.value}) probably.

Bagelfp
  • 61
  • 1
  • 7
  • Gave it a try but no avail. However as I believed it was my enviro that was the issue it turned out to be that it IS my enviro although not fixed yet I was able to replicate the issue online...https://codesandbox.io/s/znxpqmyzvp and I think I have a mismatch on react-tap-event-plugin and my react version. So all need help now with is matching/clearing my package file to match this codesandbox. – KidKode Feb 06 '18 at 00:28
  • You need to add `import injectTapEventPlugin from 'react-tap-event-plugin'; // Needed for onTouchTap // http://stackoverflow.com/a/34015469/988941 injectTapEventPlugin();` to the above sandbox though for it to work in MUItest.js – KidKode Feb 06 '18 at 00:40
  • Found the issue @Bagelfp it was duplication of root modules and files. See my other question https://stackoverflow.com/questions/48642248/is-shrinkwrap-preventing-me-from-updating-react-and-react-dom/48645855#48645855 – KidKode Feb 06 '18 at 14:58