eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

Spinner automatically scrolls to bottom when opened #60

Closed MathieuT-dot closed 4 years ago

MathieuT-dot commented 4 years ago

The Spinner in the SimpleFormDialog automatically scrolls to the bottom of the items when opened as long as no item was selected before, this may be confusing for the user.

Steps to reproduce

  1. Make SimpleFormDialog with a Spinner field.
  2. Populate the Spinner with enough items to make the Spinner scrollable.
  3. Open the Spinner.
  4. The Spinner shows the bottom of the items.

Expected and actual behaviour

I would expect that as long as there is no item selected before and no preset is used, the list would open at the top of the items. For the moment the Spinners opens at the bottom.

Test Environment

Property Value
Library version 3.1-androidx
Android version API 28
eltos commented 4 years ago

I noticed that this only happens if the selection is non-optional (i.e. required).

The reason is that the placeholder label select... is hidden in this case so the user cannot select the placeholder. This is only possible if the placeholder is at the end of the list. Thus the spinner scrolls down. If the placeholder is put at the top, then the user can select it even if a real selection is required.

The only way to prevent this, is to auto-select the first element in the list when the spinner is opened for the first time. This makes sure that the list is scrolled to the top and also ensures the user cannot select the placeholder. However the auto-selection might be confusing as well. Anyways, this is how I fixed the issue now. Are you okay with this?