Skip to content

Commit 0bfdef3

Browse files
authored
fix(AutoComplete): tabbing off AutoComplete field does not close its drop down (#5816)
* refactor: use keydown event * chore: bump version 9.56-beta02
1 parent a213b84 commit 0bfdef3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/BootstrapBlazor/BootstrapBlazor.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<Version>9.5.6-beta01</Version>
4+
<Version>9.5.6-beta02</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ export function init(id, invoke) {
4040
const duration = parseInt(input.getAttribute('data-bb-debounce') || '0');
4141
if (duration > 0) {
4242
ac.debounce = true
43-
EventHandler.on(input, 'keyup', debounce(e => {
44-
handlerKeyup(ac, e);
43+
EventHandler.on(input, 'keydown', debounce(e => {
44+
handlerKeydown(ac, e);
4545
}, duration, e => {
4646
return ['ArrowUp', 'ArrowDown', 'Escape', 'Enter', 'NumpadEnter'].indexOf(e.key) > -1
4747
}))
4848
}
4949
else {
50-
EventHandler.on(input, 'keyup', e => {
51-
handlerKeyup(ac, e);
50+
EventHandler.on(input, 'keydown', e => {
51+
handlerKeydown(ac, e);
5252
})
5353
}
5454

@@ -117,7 +117,7 @@ export function init(id, invoke) {
117117
});
118118
}
119119

120-
const handlerKeyup = (ac, e) => {
120+
const handlerKeydown = (ac, e) => {
121121
const key = e.key;
122122
const { el, input, invoke, menu } = ac;
123123
if (key === 'Enter' || key === 'NumpadEnter') {
@@ -162,6 +162,9 @@ const handlerKeyup = (ac, e) => {
162162
invoke.invokeMethodAsync('TriggerDeleteCallback', input.value);
163163
}
164164
}
165+
if (e.key === 'Tab') {
166+
ac.triggerBlur();
167+
}
165168
}
166169

167170
export function showList(id) {
@@ -189,7 +192,7 @@ export function dispose(id) {
189192
}
190193
}
191194
EventHandler.off(input, 'change');
192-
EventHandler.off(input, 'keyup');
195+
EventHandler.off(input, 'keydown');
193196
EventHandler.off(menu, 'click');
194197
Input.dispose(input);
195198

0 commit comments

Comments
 (0)