Material-ui: AutoComplete: onUpdateInput and onNewRequest functions should expose an event argument

Created on 13 Jan 2016  路  2Comments  路  Source: mui-org/material-ui

I think both these events should pass an event as parameter [IMO] 'cause i.e I can't call preventDefault() and a "Failed to load resource: the server responded with a status of 404 (Not Found)" error is thrown.

Most helpful comment

In the onUpdateInput(searchText, dataSource, params) function you have access to information on the source of the input change, namely params.source.

Actions that trigger onNewRequest will have source "TouchTap". So to prevent a state change on a new request, escape the onUpdateInput callback as follows:

onUpdateInput(searchText, dataSource, params) {
    if (params.source == 'touchTap') return;
    .......
}

All 2 comments

Same issue here, when I click on the MenuItem inside AutoComplete, onNewRequest is called and I'm redirecting to another route, however, onUpdateInput is also called, since the input is updated with the search result and I'm getting this warning.
Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component.
We should have an option to call event.stopPropagation() in onNewRequest event handler.

Any insights to why this issue was closed?
@AleffHenrique did you manage to find a workaround?

In the onUpdateInput(searchText, dataSource, params) function you have access to information on the source of the input change, namely params.source.

Actions that trigger onNewRequest will have source "TouchTap". So to prevent a state change on a new request, escape the onUpdateInput callback as follows:

onUpdateInput(searchText, dataSource, params) {
    if (params.source == 'touchTap') return;
    .......
}
Was this page helpful?
0 / 5 - 0 ratings