Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Can i manually contol the input value? #103

Closed
rburnashev85 opened this issue Jan 6, 2020 · 10 comments
Closed

Can i manually contol the input value? #103

rburnashev85 opened this issue Jan 6, 2020 · 10 comments
Labels
Resolved: By Design Resolved as behaviour is by design

Comments

@rburnashev85
Copy link

I need the standard behavior of the main search bar on many sites.

  1. If there are some suggesstions, then we give them to the user, if not, then ok, we simply let the user to search by this text.

  2. I need to manually fill the input value with some text.

  3. I also need to intercept Enter

@chrissainty
Copy link
Member

Hi, I'm sorry I'm not quite clear on your issue/request? Could you clarify your problem or your request, please?

@rburnashev85
Copy link
Author

Sorry for my English. I try to explain my issue again ) Simple example. https://www.google.com/

I can enter text there without selecting any particular suggestion. And at any time I can stop typing and click on search icon or just press Enter to start the search. Unfortunatelly, I can't achieve the same behavior from your control. I found 3 problems:

  1. I can't initialize input with some value.
  2. When the control lost focus if the text in the input doesn't match with one of the suggestions it is removed.
  3. I cannot handle pressing Enter on keyboard. (OnKeyUp doesn't work properly)

Thank you for response!

@chrissainty
Copy link
Member

Thank you for clarifying, I appreciate it's hard writing in another language, I wish I could! Let me answer your questions.

  1. It is possible to initialise the control with a preselected value, you can find an example in the sample projects

  2. This is by design, the control does not support entering arbitrary text. We're looking at adding that functionality here, Free text entry - Add item to the list. #55.

  3. This is by design, we use the enter keypress event to select whatever you have highlighted in the list. What would you want to do with the event?

@rburnashev85
Copy link
Author

  1. I want the user to be able to type arbitrary text and then press the enter button to start search. Like on google.

I hope the functionality will appear in the control. Anyway good job! The control is very useful and easy to embed. And you share your source code, so I am able to customize it to my needs by myself )

@chrissainty
Copy link
Member

chrissainty commented Jan 6, 2020

This is what happens by default with the control. The user types in their search text and presses enter, the control then calls your search method passing it the text the user has entered.

Is there something about this which doesn't fit your needs?

@rburnashev85
Copy link
Author

rburnashev85 commented Jan 7, 2020

This is exactly what I need. However, user also should be able to click special search button by mouse. In this case I somehow need to read the value of the input and run the same search method.

@chrissainty
Copy link
Member

We could potentially look at adding an optional search button. Tagging @vertonghenb for his opinion.

@vertonghenb
Copy link
Contributor

vertonghenb commented Jan 9, 2020

@chrissainty I wouldn't to be honest for the following reason.
A quote from wikipedia (it might not be the best reference but I can live with it).

For the computing feature of displaying search results while a query is typed, see typeahead find.
Typeahead is a feature of computers and software (and some typewriters) that enables users to continue typing regardless of program or computer operation—the user may type in whatever speed is desired, and if the receiving software is busy at the time it will be called to handle this later.[1] Often this means that keystrokes entered will not be displayed on the screen immediately. This programming technique for handling uses what is known as a keyboard buffer.

Basically an autocomplete is typing and getting responses as you type. Therefore a button in my humble opinion is counter intuitive and unnecessary.

On this basis, I'll go (type)ahead and close this issue

@vertonghenb vertonghenb added the Resolved: By Design Resolved as behaviour is by design label Jan 9, 2020
@vertonghenb
Copy link
Contributor

vertonghenb commented Jan 9, 2020

For others reading this post and trying to find an answer to the original question

Can I manually control the input value

  • The searchtext is not meant to be controlled and therefore you cannot control the input value.
  • You can set the initial selected value by specifying the following parameters
    • [Parameter] public TValue Value { get; set; } - Singleselect
    • [Parameter] public IList<TValue> Values { get; set; } - Multiselect

@RichardVogelij
Copy link

In my use case i'd like my users to be able to change a previously selected item (it's for a location chooser when you enter an address and a house number) - When someone chose the wrong number and tries to correct this, i'd like them to be able to focus the control - and press backspace, only changing the last couple of characters of the auto-complete component.

Currently my users have to retype the entire search string when they want to go again. It would be very helpful to be able to set the initial search text which will be entered when the control gets keyboard focus.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolved: By Design Resolved as behaviour is by design
Projects
None yet
Development

No branches or pull requests

4 participants