Skip to content

Commit 038cbd5

Browse files
committed
refactor: 移除拼音处理逻辑
1 parent e982db0 commit 038cbd5

File tree

2 files changed

+9
-22
lines changed

2 files changed

+9
-22
lines changed

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

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function init(id, invoke) {
99
const el = document.getElementById(id)
1010
const menu = el.querySelector('.dropdown-menu')
1111
const input = document.getElementById(`${id}_input`)
12-
var ac = { el, invoke, menu, input }
12+
const ac = { el, invoke, menu, input }
1313
Data.set(id, ac)
1414

1515
if (el.querySelector('[data-bs-toggle="bb.dropdown"]')) {
@@ -31,6 +31,12 @@ export function init(id, invoke) {
3131
invoke.invokeMethodAsync('OnKeyUp', e.code)
3232
})
3333
}
34+
35+
Input.composition(input, async v => {
36+
el.classList.add('is-loading');
37+
await invoke.invokeMethodAsync('TriggerOnChange', v);
38+
el.classList.remove('is-loading');
39+
})
3440
}
3541

3642
export function autoScroll(id, index) {
@@ -47,7 +53,7 @@ export function autoScroll(id, index) {
4753
active.classList.remove('active')
4854
}
4955

50-
var len = menu.children.length
56+
const len = menu.children.length
5157
if (index < len) {
5258
menu.children[index].classList.add('active')
5359
}
@@ -60,14 +66,6 @@ export function autoScroll(id, index) {
6066
}
6167
}
6268

63-
export function composition(id) {
64-
const ac = Data.get(id)
65-
if (ac) {
66-
ac.composition = true
67-
Input.composition(`${id}_input`, ac.invoke, 'TriggerOnChange')
68-
}
69-
}
70-
7169
export function triggerFocus(id) {
7270
const ac = Data.get(id)
7371
ac.popover?.show();
@@ -84,10 +82,8 @@ export function dispose(id) {
8482
EventHandler.off(ac.input, 'focus')
8583
}
8684
}
87-
if (ac.composition) {
88-
Input.dispose(`${id}_input`)
89-
}
9085
if (ac.input) {
86+
Input.dispose(ac.input)
9187
EventHandler.off(ac.input, 'keyup')
9288
}
9389
}

src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,6 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
134134
{
135135
await InvokeVoidAsync("autoScroll", Id, CurrentItemIndex.Value);
136136
}
137-
138-
if (firstRender)
139-
{
140-
// 汉字多次触发问题
141-
if (ValidateForm != null)
142-
{
143-
await InvokeVoidAsync("composition", Id);
144-
}
145-
}
146137
}
147138

148139
/// <summary>

0 commit comments

Comments
 (0)