Skip to content

Commit afdaacb

Browse files
committed
Fix bug of filter input items (#99)
1 parent fb3bb6c commit afdaacb

File tree

4 files changed

+12
-27
lines changed

4 files changed

+12
-27
lines changed

src/app/components/common/input-filter-item.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const _default = defineComponent({
1313
props: {
1414
placeholder: String
1515
},
16-
emits: ["clear", "enter"],
16+
emits: ["search"],
1717
setup(props, ctx) {
1818
const modelValue: Ref<string> = ref("")
1919
return () => h(ElInput, {
@@ -23,10 +23,11 @@ const _default = defineComponent({
2323
clearable: true,
2424
onClear() {
2525
modelValue.value = ''
26-
ctx.emit("clear")
26+
ctx.emit("search", "")
2727
},
2828
onInput: (val: string) => modelValue.value = val.trim(),
29-
onKeyup: (event: KeyboardEvent) => event.key === 'Enter' && ctx.emit("enter", modelValue.value)
29+
onKeyup: (event: KeyboardEvent) => event.key === 'Enter' && ctx.emit("search", modelValue.value),
30+
onBlur: (_event: FocusEvent) => ctx.emit("search", modelValue.value),
3031
})
3132
}
3233
})

src/app/components/limit/filter.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@ const _default = defineComponent({
3838
return () => [
3939
h(InputFilterItem, {
4040
placeholder: urlPlaceholder,
41-
onClear() {
42-
url.value = ""
41+
onSearch(searchVal: string) {
42+
url.value = searchVal
4343
handleChange()
4444
},
45-
onEnter(newVal: string) {
46-
url.value = newVal
47-
handleChange()
48-
}
4945
}),
5046
h(SwitchFilterItem, {
5147
label: onlyEnabledLabel,

src/app/components/report/filter/index.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,10 @@ const _default = defineComponent({
7272
return () => [
7373
h(InputFilterItem, {
7474
placeholder: hostPlaceholder,
75-
onClear() {
76-
host.value = ""
75+
onSearch(searchVal: string) {
76+
host.value = searchVal
7777
handleChange()
7878
},
79-
onEnter(newVal: string) {
80-
host.value = newVal
81-
handleChange()
82-
}
8379
}),
8480
h(DateRangeFilterItem, {
8581
startPlaceholder: dateStartPlaceholder,

src/app/components/site-manage/filter.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,15 @@ const _default = defineComponent({
4343
return () => [
4444
h(InputFilterItem, {
4545
placeholder: hostPlaceholder,
46-
onClear() {
47-
host.value = ""
46+
onSearch(searchVal: string) {
47+
host.value = searchVal
4848
handleChange()
4949
},
50-
onEnter(newVal: string) {
51-
host.value = newVal
52-
handleChange()
53-
}
5450
}),
5551
h(InputFilterItem, {
5652
placeholder: aliasPlaceholder,
57-
onClear() {
58-
alias.value = ""
59-
handleChange()
60-
},
61-
onEnter(newVal: string) {
62-
alias.value = newVal
53+
onSearch(searchVal: string) {
54+
alias.value = searchVal
6355
handleChange()
6456
}
6557
}),

0 commit comments

Comments
 (0)