fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

BaseAutoFill in BasePicker does not update display value as expected

Open MirandaGe opened this issue 9 years ago • 12 comments

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 avatar Feb 21 '17 04:02 MirandaGe

@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 avatar Feb 21 '17 23:02 joschect

@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: image Then I press down arrow key, the second Person resolved as matching name 'Andy Luhs': image

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?

MirandaGe avatar Feb 22 '17 07:02 MirandaGe

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:

1

2

3

Reference: http://jqueryui.com/autocomplete/#combobox

lijunle avatar Feb 22 '17 14:02 lijunle

@MirandaGe Ah, yes, that is definitely an error. Thank you for pointing that out!

joschect avatar Feb 22 '17 17:02 joschect

@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.

joschect avatar Feb 22 '17 17:02 joschect

Solution has been merged so updating the status.

gitjain avatar Mar 31 '17 21:03 gitjain

@gitjain Could you please reference the fix PR here?

lijunle avatar Apr 01 '17 01:04 lijunle

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 avatar Apr 04 '17 10:04 YusongLiu

@YusongLiu This is fixed. See codepen and attached screenshots. http://codepen.io/slimemold/pen/oZOvWW

image

image

joschect avatar Apr 04 '17 17:04 joschect

@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: peoplepicker

YusongLiu avatar Apr 05 '17 03:04 YusongLiu

Discussed with @MirandaGe and found the original issue is fixed. Thanks @joschect !

YusongLiu avatar Apr 06 '17 03:04 YusongLiu

@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.

YusongLiu avatar Apr 11 '17 10:04 YusongLiu