Picker callout acts strange when Enter is hit and the `itemLimit` is reached
Bug Report
- Package version(s): Latest
- Browser and OS versions: Firefox 61.0.1 on Windows 10 64bit
Priorities and help requested (not applicable if asking question):
Are you willing to submit a PR to fix? Yes
Requested priority: Normal
Describe the issue:
I use a Picker component with an itemLimit. When selecting the an item and hitting Enter, it reaches its itemLimit property. The Picker now ristricts further input by removing its Input field, but now the callout with suggestions stays open on the left-top corner of the viewport.
It seems that the callout with suggestions is ref'd to the Input field of the Picker. However, as the itemLimit is reached, the Input field disappears, hence the callout loses its ref and acts strange.
Actual behavior:
Expected behavior:
After hitting 'Enter' (whether the itemLimit has been reached or not) the list with suggestions disappears, until new input is been provided by the user.
If applicable, please provide a codepen repro:
NA
@joschect Expected?
Hey @basovic88 can you provide a bit more about a repro? We can reproduce it, but only if you select the same item twice. Do you have some other steps?
Just put the itemLimit={1} and you'll see that after hitting enter to select an item, the suggestions panel appears at the top left corner of the windows. This is not expected as it does not do that if you hit tab instead of enter. I'll make a codepen.
The component needs to be controlled to see the issue. Here is the codepen demonstrating the issue.
https://codepen.io/paradimeweb/pen/eLzpxR
I missed your request @joschect. Thanks @ParadimeWeb for providing the CodePen.

That's pretty weird, I'll take a look.
The problem should be a pretty easy fix. It looks like when the suggestion is completed that it just doesn't set the suggestions to no longer be visible.
Hello all,
Any updated on this bug? My users are starting to notice it more and more.
@joschect is this a quick fix you can knock out...or at least describe so that we can fix this?
@micahgodbolt this is a quick fix, I can get it done right now.
:tada:This issue was addressed in #7487, which has now been successfully released as [email protected].:tada:
Handy links:
@joschect @micahgodbolt This fix causes another more annoying issue. When a controlled DatePicker is added, the focus always goes back to the picker no matter what. Very annoying!
Here is a codepen showing the problem.
https://codepen.io/paradimeweb/pen/eLzpxR
#7487
It also does this with a DropDown and probably other components.
OK, well this is breaking issue. I added a controlled TextField to my codepen. Everytime you type in the field, you lose focus because it goes to the picker..!
https://codepen.io/paradimeweb/pen/eLzpxR
All it takes is a re-render to move the focus back. @joschect this is indeed a breaking bug. I am digging in as well, but we need to fix this asap.
Culprit is in BasePicker componentWillReceiveProps. there is no reason to be stealing focus ever here!
BasePicker.tsx (see this.resetFocus(focusIndex)):
public componentWillReceiveProps(newProps: P): void {
const newItems = newProps.selectedItems;
if (newItems) {
let focusIndex: number;
// If there are less new items than old items then something was removed and we
// should try to keep focus consistent
if (newItems.length < this.state.items.length) {
focusIndex = this.state.items.indexOf(this.selection.getSelection()[0]);
}
this.setState(
{
items: newProps.selectedItems
},
() => {
// Need to reset focus in the same that way that we do if an item is selected by a non-controlled component
// See _onSelectedItemsUpdated.
this.resetFocus(focusIndex);
}
);
}
}
Oh looks like it was fixed 5 hours ago.
https://github.com/OfficeDev/office-ui-fabric-react/commit/aab8f62851d91184b3c2ac7758dae2bc822e40bb
PR here: https://github.com/OfficeDev/office-ui-fabric-react/pull/7587
Tested and works now with v6.123.0
Thanks