Semantic-UI icon indicating copy to clipboard operation
Semantic-UI copied to clipboard

[Dropdown] - Search dropdown enter and blur couses first option selection

Open michtill opened this issue 10 years ago • 18 comments

Steps to Reproduce Enter and blur search selection dropdown with yet selected item.

  1. Select some "not first" item in the search dropdown.
  2. Again click into dropdown (in the search input, not only the arrow).
  3. Click anywhere else outside the dropdown (blur the dropdown).

Expected The dropdown should keep previesly selected item.

Result The dropdown selects the first item in the list.

Testcase http://jsfiddle.net/ba7dkjx4/

WORKAROUND forceSelection: false //but on search dropdown it should be default false

michtill avatar Aug 30 '16 18:08 michtill

I can confirm this bug

elquimista avatar Aug 30 '16 19:08 elquimista

The jsfiddle testcase is empty. I created one example here: http://jsfiddle.net/0hfpccjz/

forceSelection: false is not an easy workaround for me because this allows to set a string which is not in the dropdown.

Edit: it's also an issue on multiselect dropdowns as shown here multiselect

gizzard avatar Aug 31 '16 10:08 gizzard

Confirmed!

brunotourinho avatar Aug 31 '16 13:08 brunotourinho

I've gotten this as well

khornberg avatar Sep 01 '16 01:09 khornberg

Setting forceSelection to false solved the problem for me.

khornberg avatar Sep 01 '16 19:09 khornberg

Also happening to me in Search Dropdown. Can be reproduced using the documentation by selecting any country and if we open the dropdown again and 'blur' it it will always select the first option "Afghanistan"

** image **

PauloGraca avatar Sep 07 '16 16:09 PauloGraca

This Issue should be included into the next Release.

juice avatar Sep 19 '16 12:09 juice

We got the same issue in here.

MaikeMota avatar Oct 07 '16 12:10 MaikeMota

Try disabling selectOnKeydown by using selectOnKeydown: false, this is a separate behavior than whether it forces selection on blur.

http://jsfiddle.net/wu3r699v/

I kind of regret the naming choices, as forceSelection should have been something like selectOn: ['keydown, 'blur'] merging the two rules together and making it more clear what they actually affect.

I might actually refactor it this way while deprecating the previous settings for it to make more sense.

jlukic avatar Oct 07 '16 14:10 jlukic

In previous releases it was possible to type a few characters into the dropdown search and confirm the first selected item with tab. What do i have to do to make this work again?

juice avatar Oct 07 '16 15:10 juice

@juice forceSelection: false

jlukic avatar Oct 19 '16 00:10 jlukic

@jlukic Hi Jack, thanks for the tip, but this works only 50 percent of the time. I love this project, but right now the Dropdown part is a problem for many week. We use Dropdowns on a page with many Form Fields, most of them are generated from select fields and some of them are remote searches.

People want to type a few characters and tab to the next dropdown or text field. Right now, i have to choose between, dropdowns clear the current selection/add the first item to a multiselect or tab select is only working for some dropdowns if "forceSelection: false" is set, plus the typed characters are rendered over the selected text.

i feel like, as a default dropdowns should behave like native select fields. if you click on a dropdown, the current selection should not be cleared, the grey highlight should sit on the last selected item. i hope you can follow me. The Dropdowns worked as aspected pre 2.2.x and now it is a step by step process to see that with every release something gets fixed and something else stops working. I hope you can bring back the dropdown magic.

juice avatar Oct 31 '16 11:10 juice

function firstUnfiltered partial workaround: showOnFocus: false but after key down is selected first again

jobes avatar Nov 02 '16 20:11 jobes

@jlukic I did a little research and I see it's only for 'search multiple selection dropdown' and not for 'multiple selection dropdown', so it seems to be the combination of 'search' and 'multiple' where 'forceSelection: false' fails.

I hope that helps.

ajarti avatar Apr 13 '17 08:04 ajarti

Hi @ajarti, I can’t seem to reproduce, can you please fork this JSFiddle to create a test case?

awgv avatar Apr 13 '17 12:04 awgv

@juice Thanks, the commit you linked looks good: https://github.com/cbxp/Semantic-UI/commit/3fe5c551d35e7bb8463102a62feafe0b89c0e414

lauri-elevant avatar May 03 '17 10:05 lauri-elevant

Can anyone provide a JSfiddle showing this issue in the current version?

I'm testing in latest with multiple search selection dropdown and am not seeing it selecting incorrect value. Perhaps I'm not reproing correctly?

jlukic avatar Jul 03 '17 02:07 jlukic

Oh hey.. this appears to be fixed in next release, but not current release.

Apparently I noticed this on my own and fixed without linking back to this issue https://github.com/Semantic-Org/Semantic-UI/commit/238ac3c8906330e0fcc1980fefeea0ae2dfb2bda

This will go out with 2.2.11 on tuesday.

And yes.. previous behavior was very annoying and incorrect, apologies.

jlukic avatar Jul 03 '17 02:07 jlukic