How to programmatically select an option without triggering onChange
?
#5958
Unanswered
oliveryasuna
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to programmatically select an option without triggering events?
Here is my current solution (and we have been using this in production):
That approached worked fine. The input value is visually updated and I can track the option in a state.
However, I noticed something today... If I set the option using the above approach, then focus on the select, the input is cleared. This is not normal behavior, as if I select an option from the overlay and then focus again on the select, or use
selectOption
and then focus on the select, the input value stays the same. It seems that my approach does not keep the state of the select component in sync. If I select a value from the dropdown, then use the code above, when I focus again, it reverts the input value to the value I selected from the dropdown.I cannot use
select.setValue
, as this will trigger events. I tried rewriting whatselectOption
does (without calling listeners), and that did not work.Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions