angular / material

Material design for AngularJS
https://material.angularjs.org/
MIT License
16.54k stars 3.39k forks source link

mdAutocomplete: does not Autoselect correctly #8863

Closed hollsteinm closed 8 years ago

hollsteinm commented 8 years ago

Actual behavior:

CodePen or Steps to reproduce the issue: *

Angular Versions: *

Additional Information:


Shortcut to create a new CodePen Demo. Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

devversion commented 8 years ago

So I was looking at the source.

The md-autcomplete only auto selects, if there is only one possible match.

So since there are many matches, if you just enter A, the autocomplete will not detect that as an exact match. (See in source)

image

It's actually not a bug and it seems to work as expected in my opinion.

@hollsteinm I would be very happy to discuss about that.

Also I will talk to the Team today and try to re-validate the logic.

hollsteinm commented 8 years ago

Hi, thank you for pointing that out to me. (Guess I didn't read it as closely as I thought). The only problem is that the use case involved selecting a range of numbers that were used as identification. The values were a range of one to three digit numbers. Of course these identifiers had to be filtered out so I could not just do a range, and thus were queried from the database. I think the biggest issue is that if the mdAutcomplete contained a value and 'Enter' was pressed to complete the action, mdAutocomplete would not submit the value in the text field.

hollsteinm commented 8 years ago

Hi, I actually updated this behaviour in the code pen. Type in "A" and hit Enter. It will notify null, rather than the value in the field. http://codepen.io/anon/pen/zBZYOb. Would you like me to update the bug to reflect this issue or write a new one?

devversion commented 8 years ago

Actually I don't think that's also an issue, since it's the browsers default behavior to submit the form on enter (when focus is on the input)

If you select your choice with the Arrow Keys and then press Enter, it select the value as expected.

mckenzielong commented 8 years ago

@DevVersion Probably considered an enhancement, but what about the idea of autoselect on focus loss + match?

Suppose we have directions: N, NW, NE. Currently: user types N and tabs off the field -- no item is selected. Folks who do data entry might appreciate a feature where we auto select when focus is lost if there is a match (saving 2+ keystrokes to filter down and press enter.) -- user types N, tabs off -- N item is selected.

devversion commented 8 years ago

@mckenzielong Can you file this as an extra issue, so I can discuss it with the team?

devversion commented 8 years ago

Closing this issue for now, because it's actually not a bug, just some wrong understanding.

FYI: About discussing with the team, this will be not possible, because we only support exact matches here.

hollsteinm commented 8 years ago

@DevVersion The only thing is, "A" is technically an exact match. So shouldn't the statement be "An exact match if it is the only option available".

What I am getting at is that the documentation should be updated to be more clear about this case. Hence, why it was a bug (or at least misunderstood).

devversion commented 8 years ago

@hollsteinm Seems to be reasonable request to update the docs. Thanks.