Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickers select items on suggestions dismissal after first selection even when input is empty #3349

Closed
Nimelrian opened this issue Nov 9, 2017 · 7 comments · Fixed by #3610

Comments

@Nimelrian
Copy link
Contributor

Bug Report

  • Package version(s):
    • office-ui-fabric-react: 5.20.0
    • react: 16.0.0
    • react-dom: 16.0.0
  • Browser and OS versions: Chrome Version 62.0.3202.62 / Windows 10 Pro Version 1703

Priorities and help requested (not applicable if asking question):

Are you willing to submit a PR to fix? No

Requested priority: Normal

Describe the issue:

When using a picker (e.g. a simple tag picker) and using the onEmptyInputFocus prop, dismissing the suggestion dropdown causes items to be selected after an item has been initially picked.

Actual behavior:

When dismissing the suggestions with a click outside the dropdown, an item gets selected (from what I can tell it's always the first suggestion) even if the input is empty.

Expected behavior:

When dismissing the suggestions with a click outside the dropdown and when the input is empty, the input should lose focus, the suggestions should get dismissed and no item should be added.

If applicable, please provide a codepen repro:

CodeSandbox instead of codepen, but does the same job:

https://codesandbox.io/s/4q77p02l10

@Nimelrian Nimelrian changed the title Pickers select items on dismiss after first selection even when input is empty Pickers select items on suggestions dismissal after first selection even when input is empty Nov 9, 2017
@amadeogallardo
Copy link

I'm also able to reproduce this issue. @Nimelrian did you find a hotfix to apply on application code? Possibly handling some of the provided events for onBlur, onFocus, onEmptyInputFocus, etc.?

@micahgodbolt
Copy link
Member

I was not able to repro this in codepen. I added more text below the picker to make it easier to click. https://codepen.io/micahgodbolt/pen/VyjWam

@Nimelrian
Copy link
Contributor Author

Nimelrian commented Dec 20, 2017

@micahgodbolt

  1. Click into picker, suggestions drop down
  2. Click cyan
  3. Click outside of picker (doesn't have to be on the text), just blur it
  4. Click inside picker, suggestions drop down again
  5. Click on text
  6. black will be added

@micahgodbolt
Copy link
Member

Yeah, it's kind finicky. I was able to get it to repro eventually.

@micahgodbolt
Copy link
Member

If you load the page fresh and click in and then click out, it works fine. But as soon as you click on an item once...or up/down arrow once, it starts grabbing whatever you have focus on.

@micahgodbolt
Copy link
Member

While I have no trouble with an onDismiss callback (with some tweaks I mentioned), I feel thats a bit of a bandaid. I'll check with the author of that code and see if he has feedback on why it's written that way.

@micahgodbolt
Copy link
Member

After a bit of a chat what we determined was that pickers were really never meant to act as dropdown selectors. They always took some input, filtered the list based on that input and then inserted your selection. That also meant if you half selected a word and moved focus away, that selected word would populate the picker. That's an expected behavior that is causing trouble for you because you aren't filtering your suggestions.

picker

But I totally get your usecase. Often you'll have a small list you want people to choose from and you don't want them to need to type to discover them. So I think for now, the best approach is an onDismiss callback (with the modifications I mentioned). This may not be the way we handle this in future, but a callback function adds value and will meet your needs for now.

@microsoft microsoft locked as resolved and limited conversation to collaborators Aug 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants