I have an InputField, when the length of the String entered in the InputField becomes 0, it should display a toast and on closing the Toast, the Focus should come back to InputField?

Here I am able to display a Toast Properly but due to toast, I am losing focus from the InputField?

closed as off-topic by Raul, battery.cord, glls, Oleksandr Berehovskyi, Gortonington Nov 22 '17 at 14:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Raul, battery.cord, glls, Oleksandr Berehovskyi, Gortonington
If this question can be reworded to fit the rules in the help center, please edit the question.


You have a duration attribute in lightning toast method. Once the toast method is fired using. toastEvent.fire();

you can use javascript setTimeout method of the same duration and In that method, you can use javascript to set focus on particular input with particular id like this.


or you can use cmp.get("v.Input"); to get the input and set it focus in similar way.

Not the answer you're looking for? Browse other questions tagged or ask your own question.