alsoscotland / react-super-select

MIT License
95 stars 33 forks source link

Auto focus on ajax search? #126

Closed noahkconley closed 7 years ago

noahkconley commented 7 years ago

I'm trying to configure my ajax search so that the searchable input element autofocuses when the dropdown opens. This works perfectly for non-ajax search, or if the ajax dropdown is opened a second time with the data already fetched, but it doesn't seem to work on the initial data fetch.

At initial state there is no lastUserSelectedOption, so _setFocusOnOpen passes to _moveFocusDown, which returns because _needsAjaxFetch is true. In _fetchDataViaAjax, it doesn't move the focus to the search field unless openOnMount and focusOnMount are both true.

Is there any way to configure this now? If not, could there be functionality to either move the focus during or after an ajax call, or if the fetchAjaxData function is defined, call it once the component is mounted?

screen shot 2017-10-13 at 11 27 40 am

alsoscotland commented 7 years ago

@gallardo1226 That seems like an oversight that the input does not focus while fetching occurs. I will take a look

noahkconley commented 7 years ago

Much appreciated!

alsoscotland commented 7 years ago

@gallardo1226 Thanks for filing the issue. Should be addressed in the latest https://github.com/alsoscotland/react-super-select/tree/v1.0.8

noahkconley commented 7 years ago

Thanks for addressing it so quickly!