fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Picker callout acts strange when Enter is hit and the `itemLimit` is reached

Open bt-88 opened this issue 8 years ago • 27 comments

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

bt-88 avatar Jul 20 '18 06:07 bt-88

@joschect Expected?

dzearing avatar Jul 23 '18 20:07 dzearing

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?

joschect avatar Jul 23 '18 20:07 joschect

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.

ParadimeWeb avatar Aug 28 '18 02:08 ParadimeWeb

The component needs to be controlled to see the issue. Here is the codepen demonstrating the issue.

https://codepen.io/paradimeweb/pen/eLzpxR

ParadimeWeb avatar Aug 28 '18 02:08 ParadimeWeb

I missed your request @joschect. Thanks @ParadimeWeb for providing the CodePen.

bt-88 avatar Aug 28 '18 05:08 bt-88

picker

micahgodbolt avatar Aug 30 '18 16:08 micahgodbolt

That's pretty weird, I'll take a look.

joschect avatar Aug 30 '18 16:08 joschect

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.

joschect avatar Aug 30 '18 18:08 joschect

Hello all,

Any updated on this bug? My users are starting to notice it more and more.

ParadimeWeb avatar Nov 18 '18 20:11 ParadimeWeb

@joschect is this a quick fix you can knock out...or at least describe so that we can fix this?

micahgodbolt avatar Dec 27 '18 23:12 micahgodbolt

@micahgodbolt this is a quick fix, I can get it done right now.

joschect avatar Dec 28 '18 00:12 joschect

:tada:This issue was addressed in #7487, which has now been successfully released as [email protected].:tada:

Handy links:

msft-github-bot avatar Dec 31 '18 13:12 msft-github-bot

@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

ParadimeWeb avatar Jan 10 '19 01:01 ParadimeWeb

It also does this with a DropDown and probably other components.

ParadimeWeb avatar Jan 10 '19 01:01 ParadimeWeb

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

ParadimeWeb avatar Jan 10 '19 01:01 ParadimeWeb

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.

dzearing avatar Jan 10 '19 04:01 dzearing

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);
        }
      );
    }
  }

dzearing avatar Jan 10 '19 04:01 dzearing

Oh looks like it was fixed 5 hours ago.

https://github.com/OfficeDev/office-ui-fabric-react/commit/aab8f62851d91184b3c2ac7758dae2bc822e40bb

dzearing avatar Jan 10 '19 04:01 dzearing

PR here: https://github.com/OfficeDev/office-ui-fabric-react/pull/7587

dzearing avatar Jan 10 '19 04:01 dzearing

Tested and works now with v6.123.0

Thanks

ParadimeWeb avatar Jan 10 '19 05:01 ParadimeWeb