material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

AutoComplete: TypeError: key.includes is not a function

Open nslobodchuk opened this issue 11 years ago • 1 comments

Hi,

I'm trying AutoComplete examples from the docs and I'm getting this error in console "TypeError: key.includes is not a function". It references line 59 in auto-complete.js. My code is simply:

<AutoComplete floatingLabelText = "floating Label" dataSource = {["12345", "23456", "34567"]} />

Am I doing something wrong?

PS. I ran the same the code again and there was no error. Maybe this was a problem with my browser or gulp.

nslobodchuk avatar Dec 01 '15 14:12 nslobodchuk

I' ve encountered the same problem in Safari. I think simply String.inludes() is not supported, I've fixed it modifing the filter function in the path 'material-ui/lib/auto-complete.js' in this way:

 filter: function filter(searchText, key, value) {

    if (!String.prototype.includes) {
      String.prototype.includes = function() {'use strict';
        return String.prototype.indexOf.apply(this, arguments) !== -1;
      };
    }
   return key.includes(searchText);
  }

francescabarbazeni87 avatar Jan 25 '16 14:01 francescabarbazeni87