reactjs / react-autocomplete

WAI-ARIA compliant React autocomplete (combobox) component
MIT License
2.17k stars 532 forks source link

Can't select item from the menu in IE11 #257

Open milencheto opened 7 years ago

milencheto commented 7 years ago

Hi, guys... I have a problem on IE11. When I open the menu, it shows my list, but I can't click on it to choosing some option. It looks like IE11 recognize the items just like a text but not links.. Can you help me?

CMTegner commented 7 years ago

Hi Milena! Can you provide a reduced test case so we can help debug this problem? Perhaps it's reproducible in one of the examples?

milencheto commented 7 years ago

https://github.com/facebook/react/issues/6614 It looks like other people have the same and more problems with this component.

CMTegner commented 7 years ago

I'm not sure how that React core issue relates to your original description. Is the autofill some how preventing you from selecting items from the menu?

gregdillon commented 7 years ago

I just noticed this issue the latest version of Safari as well.

UPDATE: So it looks like Safari is requiring a double-click on the item to select, versus a single-click in chrome. May not be related to the original issue.

CMTegner commented 7 years ago

@gregdillon seems like the examples work fine (i.e. only require a single click to select) in Safari. Can you provide a reduced test case that demonstrates the problem?

gregdillon commented 7 years ago

@CMTegner I'll keep looking. Not sure what is going on and it may be my implementation. I'll report back if/when I figure out. Thanks.

rek commented 7 years ago

Any news? I also have this issue with IE11 and EDGE.

CMTegner commented 7 years ago

@rek can you create a reduced test case which reproduces the error?

rek commented 7 years ago

Working on it :)

rek commented 7 years ago

Is there a JSFiddle or anything I can start from to try and reproduce this there?

CMTegner commented 7 years ago

@rek try this JSBin: http://jsbin.com/mipesawapi/edit?js,output

rek commented 6 years ago

We found a fix for this. Our problem was in our implementation. It was because we had a dynamic Id in the inputProps.id directly, once we changed this it started working.

Here is what we changed it to:

import AutocompleteBase from 'autocomplete'

export class AutoComplete extends React.Component {
    autoCompleteId = _.uniqueId(this.props.id || 'autocomplete-')
    ...
    render() {
        ...

        return (
            <AutocompleteBase
                inputProps={{
                    name: this.props.title,
                    id: this.autoCompleteId,
                }}
                ...
            />
        )
    }
}
dennisat commented 5 years ago

@rek this didn't work for me. Also without id didn't work either.

dennisat commented 5 years ago

I found the bug in my code. The key in the shouldItemRender should be unique id per item and not new value.

In shouldItemRender as key of the JSX Element, I was assigned a different value always.

So I had something like this: shouldItemRender={(item, value)=><div key={this.cheapGuid++}>{value}</div>}

Yeah, I know, it is anti-pattern since it renders all the items always but I had no unique id there.

For some reason, in MS Browsers (IE11 & Edge) the items are not clickable till you assign a unique key for each item as key in shouldItemRender.

Ensure that the key is unique, otherwise, the items might flicker.