Skip to content

Commit b1bfeda

Browse files
dimodidimodi
authored andcommitted
kb(ComboBox): Fix corner case
1 parent e4ea494 commit b1bfeda

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

knowledge-base/combobox-auto-select-on-blur.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ To automatically select the first matching item in the ComboBox when the input l
6666
<ComboBoxPopupSettings Class="select-on-tab" />
6767
</ComboBoxSettings>
6868
</TelerikComboBox>
69-
<br/>
70-
<br/>
71-
<TelerikTextBox Placeholder="Next form item" Width="200px"/>
69+
<br />
70+
<br />
71+
<TelerikTextBox Placeholder="Next form item" Width="200px" />
7272
7373
@* Move JavaScript to a separate JS file *@
7474
<script suppress-error="BL9992">
75-
function attachComboKeyDown(selector) {
75+
function attachComboKeyDown(selector) {
7676
var comboInput = document.querySelector(selector);
7777
if (comboInput) {
7878
comboInput.addEventListener("keydown", onComboInputKeyDown);
@@ -100,7 +100,7 @@ To automatically select the first matching item in the ComboBox when the input l
100100
</script>
101101
102102
@code {
103-
private DotNetObjectReference<__Main>? DotNetRef { get; set; }
103+
private DotNetObjectReference<Counter>? DotNetRef { get; set; }
104104
105105
private List<ListItem> ComboBoxData { get; set; } = new();
106106
private int ComboBoxValue { get; set; }
@@ -109,7 +109,7 @@ To automatically select the first matching item in the ComboBox when the input l
109109
[JSInvokable("OnComboBoxTab")]
110110
public void OnComboBoxTab(string newStringValue)
111111
{
112-
if (ComboBoxFirstItem is not null && ComboBoxFirstItem.Text.Contains(newStringValue))
112+
if (ComboBoxFirstItem is not null && ComboBoxFirstItem.Text.ToLowerInvariant().Contains(newStringValue.ToLowerInvariant()))
113113
{
114114
ComboBoxValue = ComboBoxFirstItem.Id;
115115
ComboBoxFirstItem = default;
@@ -131,7 +131,7 @@ To automatically select the first matching item in the ComboBox when the input l
131131
args.Data = result.Data;
132132
args.Total = result.Total;
133133
134-
if (args.Request.Filters.Count > 0)
134+
if (args.Request.Filters.Count > 0 && result.Data.Cast<ListItem>().Count() > 0)
135135
{
136136
ComboBoxFirstItem = args.Data.Cast<ListItem>().First();
137137
}
@@ -160,10 +160,10 @@ To automatically select the first matching item in the ComboBox when the input l
160160
for (int i = 1; i <= 24; i++)
161161
{
162162
ComboBoxData.Add(new ListItem()
163-
{
164-
Id = i,
165-
Text = $"Item {i}"
166-
});
163+
{
164+
Id = i,
165+
Text = $"Item {i}"
166+
});
167167
}
168168
}
169169
@@ -182,4 +182,4 @@ To automatically select the first matching item in the ComboBox when the input l
182182
````
183183
## See Also
184184

185-
- [ComboBox Events](slug:components/combobox/events)
185+
- [ComboBox Events](slug:components/combobox/events)

0 commit comments

Comments
 (0)