reactjs / react-autocomplete

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

[fixed] Fix dropdown not closing on selection in IE #246

Closed rssteffey closed 7 years ago

rssteffey commented 7 years ago

Issue #153

I suspect a change since this ticket was first opened has broken it again. Example pages do not close menu on selection in IE11. This adds the fix back into the inputBlur handler

CMTegner commented 7 years ago

Hi Shawn! Thanks for bringing this to our attention, and sorry for the late response. I've been beating my head against the wall, trying to solve the "focus management" problem for the past 4-5 days. I've finally managed to release something (1.5.9) that seems to handle all of the edge cases.

This specific issue should of course never have regressed, but since I didn't add a test for it the first time I fixed it, I guess I had it coming ¯_(ツ)_/¯

The reason why I didn't accept your fix is that it caused the logic which is supposed to preserve focus and keep the menu open, to become unsynced and stop working properly. You could provoke this by clicking on a non-item element within the menu (e.g. a scrollbar or some padding on the menu), and then try to select an item. The second blur would case the menu to close before the item got selected, since the ignoreBlur flag had been reset.

You can read more about how I solved this and related problems in the commit message.