Skip to content

Commit ee29501

Browse files
authored
fix(AutoComplete): shoud trigger ValueChanged after enter (#7281)
1 parent 8782291 commit ee29501

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { debounce, registerBootstrapBlazorModule } from "../../modules/utility.js"
1+
import { debounce, registerBootstrapBlazorModule } from "../../modules/utility.js"
22
import { handleKeyUp, select, selectAllByFocus, selectAllByEnter } from "../Input/BootstrapInput.razor.js"
33
import Data from "../../modules/data.js"
44
import EventHandler from "../../modules/event-handler.js"
@@ -153,18 +153,22 @@ const handlerKeydown = (ac, e) => {
153153
if (key === 'Enter') {
154154
const skipEnter = el.getAttribute('data-bb-skip-enter') === 'true';
155155
if (!skipEnter) {
156+
let activeItem = null;
156157
const items = [...menu.querySelectorAll('.dropdown-item')];
157158
if (items.length === 1) {
158-
const item = items[0];
159-
item.click();
159+
activeItem = items[0];
160160
}
161161
else {
162-
const current = menu.querySelector('.active');
163-
if (current !== null) {
164-
current.click();
165-
}
162+
activeItem = menu.querySelector('.active');
166163
}
167-
invoke.invokeMethodAsync('EnterCallback');
164+
165+
const handler = setTimeout(async () => {
166+
clearTimeout(handler);
167+
if (activeItem !== null) {
168+
activeItem.click();
169+
}
170+
await invoke.invokeMethodAsync('EnterCallback');
171+
}, 0);
168172
}
169173
}
170174
else if (key === 'Escape') {

0 commit comments

Comments
 (0)