Skip to content

Commit 7a5c8ea

Browse files
authored
fix(AutoComplete): missing value when click delete item (#5817)
* refactor: 增加 keyup 事件回调 * chore: bump version 9.5.6-beta03
1 parent 0bfdef3 commit 7a5c8ea

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
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-beta02</Version>
4+
<Version>9.5.6-beta03</Version>
55
</PropertyGroup>
66

77
<ItemGroup>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@ export function init(id, invoke) {
4141
if (duration > 0) {
4242
ac.debounce = true
4343
EventHandler.on(input, 'keydown', debounce(e => {
44-
handlerKeydown(ac, e);
44+
handlerKeydown(e);
4545
}, duration, e => {
4646
return ['ArrowUp', 'ArrowDown', 'Escape', 'Enter', 'NumpadEnter'].indexOf(e.key) > -1
4747
}))
4848
}
4949
else {
5050
EventHandler.on(input, 'keydown', e => {
51-
handlerKeydown(ac, e);
51+
handlerKeydown(e);
5252
})
5353
}
5454

55+
EventHandler.on(input, 'keyup', e => handlerKeyup(ac, e));
56+
5557
ac.triggerBlur = () => {
5658
el.classList.remove('show');
5759
const triggerBlur = input.getAttribute('data-bb-blur') === 'true';
@@ -117,7 +119,7 @@ export function init(id, invoke) {
117119
});
118120
}
119121

120-
const handlerKeydown = (ac, e) => {
122+
const handlerKeyup = (ac, e) => {
121123
const key = e.key;
122124
const { el, input, invoke, menu } = ac;
123125
if (key === 'Enter' || key === 'NumpadEnter') {
@@ -162,6 +164,9 @@ const handlerKeydown = (ac, e) => {
162164
invoke.invokeMethodAsync('TriggerDeleteCallback', input.value);
163165
}
164166
}
167+
}
168+
169+
const handlerKeydown = e => {
165170
if (e.key === 'Tab') {
166171
ac.triggerBlur();
167172
}
@@ -193,6 +198,7 @@ export function dispose(id) {
193198
}
194199
EventHandler.off(input, 'change');
195200
EventHandler.off(input, 'keydown');
201+
EventHandler.off(input, 'keyup');
196202
EventHandler.off(menu, 'click');
197203
Input.dispose(input);
198204

0 commit comments

Comments
 (0)