Skip to content

Commit a78335a

Browse files
committed
revert: 重构代码
1 parent 2b5bcbe commit a78335a

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,18 @@ export function init(id, invoke) {
1717
ac.popover = Popover.init(el, { toggleClass: '[data-bs-toggle="bb.dropdown"]' });
1818
}
1919

20-
// Track the current user input to prevent it from being overwritten
21-
ac.currentUserInput = input.value;
22-
23-
// Save original input value
24-
const updateCurrentInput = (e) => {
25-
if (e && e.target) {
26-
ac.currentUserInput = e.target.value;
27-
}
28-
};
29-
30-
// Add an input event listener to track user typing in real-time
31-
EventHandler.on(input, 'input', updateCurrentInput);
32-
3320
// debounce
3421
const duration = parseInt(input.getAttribute('data-bb-debounce') || '0');
3522
if (duration > 0) {
3623
ac.debounce = true
3724
EventHandler.on(input, 'keyup', debounce(e => {
38-
// Don't let the debounce overwrite what the user is currently typing
39-
if (input.value !== ac.currentUserInput) {
40-
input.value = ac.currentUserInput;
41-
}
4225
handlerKeyup(ac, e);
4326
}, duration, e => {
4427
return ['ArrowUp', 'ArrowDown', 'Escape', 'Enter', 'NumpadEnter'].indexOf(e.key) > -1
4528
}))
4629
}
4730
else {
4831
EventHandler.on(input, 'keyup', e => {
49-
// Make sure we're using the most current input value
50-
updateCurrentInput(e);
5132
handlerKeyup(ac, e);
5233
})
5334
}
@@ -83,24 +64,11 @@ export function init(id, invoke) {
8364
filterDuration = 200;
8465
}
8566
const filterCallback = debounce(async v => {
86-
// Keep track of what was filtered vs what might be currently typed
87-
const currentTypedValue = input.value;
88-
8967
await invoke.invokeMethodAsync('TriggerFilter', v);
90-
91-
// Only reset input value if the user hasn't typed something new
92-
// during the async operation
93-
if (input.value === v) {
94-
input.value = ac.currentUserInput;
95-
}
96-
9768
el.classList.remove('is-loading');
9869
}, filterDuration);
9970

10071
Input.composition(input, v => {
101-
// Update our tracked input value
102-
ac.currentUserInput = v;
103-
10472
if (isPopover === false) {
10573
el.classList.add('show');
10674
}
@@ -199,7 +167,6 @@ export function dispose(id) {
199167
}
200168
EventHandler.off(input, 'change');
201169
EventHandler.off(input, 'keyup');
202-
EventHandler.off(input, 'input'); // Remove the input event listener we added
203170
EventHandler.off(menu, 'click');
204171
Input.dispose(input);
205172

0 commit comments

Comments
 (0)