This is a migrated thread and some comments may be shown as answers.

How to handle Tab key pressed in AutoComplete?

2 Answers 906 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
nick2017
Top achievements
Rank 1
nick2017 asked on 29 Oct 2019, 05:37 PM

Is there any way to handle Tab key pressed event in the AutoComplete component? 

My use case is to keep the component stayed focus when users hit the Tab and show an error message if the entered text is invalid. Please advice.

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 30 Oct 2019, 07:21 AM

Hello,

This can be achieved by use the component ref and attaching a keydown event listener to the input.

Then inside the event check for the tap keycode.

This is an example:

https://stackblitz.com/edit/react-cw51ay?file=app/main.jsx

I hope this is helpful.

Regards,
Stefan
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
nick2017
Top achievements
Rank 1
answered on 30 Oct 2019, 03:56 PM

Thank you Stefan,

Also got the same approach on yesterday

Tags
General Discussions
Asked by
nick2017
Top achievements
Rank 1
Answers by
Stefan
Telerik team
nick2017
Top achievements
Rank 1
Share this question
or