MudBlazor icon indicating copy to clipboard operation
MudBlazor copied to clipboard

MudAutoComplete bound value not being set if user presses Tab key

Open AFAde opened this issue 2 years ago • 3 comments

Bug type

Component

Component name

MudAutoComplete

What happened?

If you type in an item which is found by the search function and immediately after press Tab to move the focus out the field without pressing enter or clicking of the item from the drop down list, the value of the bound property is not set. The same happens if you copy/paste a into the autocomplete field. Funnily enough, if you type in a value which is NOT found by the search function, the bound property is correctly set.

See attached recording MudAutoSelectIssue

Expected behavior

The value of the bound property is set upon leaving the field. The value of the bound property is set after a copy paste

Reproduction link

https://try.mudblazor.com/snippet/GOQGOfkqHOWvXzRp

Reproduction steps

  1. Define an Autocomplete field with
  2. Type a value into the field. The value must be a known one (namely, the search function can find it)
  3. Press Tab to move the focus out the field (do not click on the item in the drop down list)
  4. Repeat from 2. but copy/paste instead of typing

Relevant log output

No response

Version (bug)

6.*

Version (working)

No response

What browsers are you seeing the problem on?

Firefox

On what operating system are you experiencing the issue?

Windows

Pull Request

  • [ ] I would like to do a Pull Request

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

AFAde avatar May 06 '22 08:05 AFAde

You need to use SelectValueOnTabparameter.

https://try.mudblazor.com/snippet/QYGwaAceqxgLIjts

And i doesn't see any problem about paste. Could you confirm?

mckaragoz avatar Jun 24 '22 17:06 mckaragoz

This is problematic. Yes you can use SelectValueOnTab to solve the issue but ONLY when using tab. If the user just clicks outside the field the value is NOT set. Even with CoerceValue set to true.

So when typing the correct string and NOT selecting it in the dropdown. Or when pasting it in, the value is not set when focus is lost without using tab or enter.

The value displays but is it not set in those cases.

Instead of SelectValueOnTab we need something like SelectValueOnLoseFocus. But I would argue that should not be nessesary when using CoerceValue.

Sevenish avatar Sep 08 '22 10:09 Sevenish

@mckaragoz yes, that works

AFAde avatar Jun 21 '23 09:06 AFAde