You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* How can I configure the ComboBox to automatically select the first matching item when the input loses focus (e.g., when the user tabs away or clicks outside)?
27
-
* How do I auto-select a ComboBox item based on user input when focus is lost?
26
+
* How to configure the ComboBox to automatically select the first matching item when the input loses focus (e.g., when the user tabs away or clicks outside)?
27
+
* How to auto-select a ComboBox item based on user input when focus is lost?
28
28
* Can the ComboBox select a suggested item on blur without pressing Enter?
29
29
* How to set the ComboBox value when the user leaves the input field?
30
30
31
31
## Solution
32
-
To automatically select the first matching item in the ComboBox when the input loses focus (on blur), follow these steps:
32
+
To automatically select the first matching item in the ComboBox when the input loses focus, use a combination of the ComboBox [`OnRead` event](slug:components/combobox/events#onread) and JavaScript interop. The provided example demonstrates how to:
33
33
34
-
1.Handle the [`OnBlur` event](slug:components/combobox/events#onblur) of the ComboBox to detect when the input loses focus.
35
-
2.Retrieve the currently highlighted or filtered item using a JavaScript helper function via `JS interop`.
36
-
3.Check for a matching item in the ComboBox data based on the user's input.
37
-
4.Set the matching item as the selected value programmatically.
34
+
1.Use the `OnRead` event to filter data and store the first matching item.
35
+
2.Attach a JavaScript event handler to detect when the user blurs the ComboBox input.
36
+
3.Invoke a .NET method from JavaScript to set the ComboBox value to the first matching item when focus is lost.
37
+
4.Update the ComboBox selection programmatically and refresh the UI.
38
38
39
39
>caption Auto-select the first matching item on blur
0 commit comments