BaseAutoFill in BasePicker does not update display value as expected
Bug Report
- Package version(s): any
- Browser and OS versions: any
Describe the issue:
We use BasePicker to realize customized PeoplePicker with datasource in odsp-shared-react.
Sometimes it seems very strange when we use up/down arrow key to switch between items in suggestion list, the displayed value in input area doesn't change when datasource has resolved our input query correctly.
Actual behavior:
I look into the reason of it. In BaseAutoFill, there is some actions taken before render() function is called:
public componentWillReceiveProps(nextProps: IBaseAutoFillProps) {
if (this._autoFillEnabled && this._doesTextStartWith(nextProps.suggestedDisplayValue, this._value)) {
this.setState({ displayValue: nextProps.suggestedDisplayValue });
}
}
It will check whether the resolved result begins with query or not ant then setState, which means when my input is 'luh', and the datasource resolve it as 'Elika Luhur (Adecco)', the result won't be updated and displayed in input area. This is not what we expect.
However, it seems like a designed behavior of BaseAutoFill?
@MirandaGe Hi. BaseAutoFill was designed to be like this. If the text doesn't match, where should the cursor placement be? Which text should be highlighted? How should the cursor be placed when you select a different person with a different name?
You might be able to get it working somewhat by passing in a different function to getTextFromItem so that the text returned could be "Luhur, Elika" or something like that..
@joschect Hi, we understand that there are some related behavior of input related to whether the resolved result match it or not. But we thought the way we deal with it is not natural, for example:
I input 'luh', and the first person is resolved successfully:
Then I press down arrow key, the second Person resolved as matching name 'Andy Luhs':

However because of the name is not begin with 'luh', the input value is not changed and keeps showing last value. It's strange.
So, the expected behavior is, when such things happen, it shows 'luh' without resolved value. What do you think?
Hey, @joschect
Hi. BaseAutoFill was designed to be like this. If the text doesn't match, where should the cursor placement be?
I don't think it is a common pattern to filter the text only startWith the uesr input. Here are community scenarios:



Reference: http://jqueryui.com/autocomplete/#combobox
@MirandaGe Ah, yes, that is definitely an error. Thank you for pointing that out!
@lijunle You are correct that is the way that autocomplete works in a variety of places. It almost seems like there should be different types. The autofill I wrote is supposed work more as suggested text, rather than completely replacing the text in the textfield. That said it is in a strange middleground right now.
Solution has been merged so updating the status.
@gitjain Could you please reference the fix PR here?
The problem is not fixed yet. We need to re-open the issue.
In the PeoplePicker examples, we have:
<ListPeoplePicker
onResolveSuggestions={ this._onFilterChanged }
...
/>
In _onFilterChanged it will always use this._doesTextStartWith to filter suggestions:
private _filterPersonasByText(filterText: string): IPersonaProps[] {
return this._peopleList.filter(item => this._doesTextStartWith(item.primaryText, filterText));
}
So we cannot repro it using the existing Fabric-React examples.
To repro it, we could add and use a different filter like this._doesTextContains.
In this way, all the persona that contain the typed input will show in the suggestion list, but only the one start with the typed input could be updated in the input box when navigated to it. That's the issue @MirandaGe mentioned.
@YusongLiu This is fixed. See codepen and attached screenshots. http://codepen.io/slimemold/pen/oZOvWW


@joschect I tried your demo but found the issue is still there. Only the suggestions that start with the typed input will be updated in the input box:

Discussed with @MirandaGe and found the original issue is fixed. Thanks @joschect !
@joschect Today we found the issue is still existing. We just found your codepen uses //spoppe-a.akamaihd.net/files/fabric/office-ui-fabric-react/latest/office-ui-fabric-react.min.js which is on an old version.
Please try the codepen with the [email protected]:
http://codepen.io/ysliu/pen/MmgbRq
The issue still exists.