Skip to content

Commit 8ddcfca

Browse files
committed
UseSarch fix
1 parent d3a7c28 commit 8ddcfca

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue3-hive-ui-kit",
33
"private": false,
4-
"version": "0.7.22",
4+
"version": "0.7.23",
55
"type": "module",
66
"description": "UI kit for Vue 3",
77
"files": [

src/common/hooks/use-list-methods.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,28 @@ export const useListMethods = ({
128128
};
129129

130130
let stopWatchSearch = watch(searchQuery, () => {
131-
useSearch(currentOptions, searchQuery.value, currentValue.value, fieldTitle, fieldValue, filteredOptions, distinct);
131+
useSearch(
132+
currentOptions,
133+
searchQuery.value,
134+
currentValue.value,
135+
fieldTitle,
136+
fieldValue,
137+
filteredOptions,
138+
distinct,
139+
withNull,
140+
);
132141
});
133142

134-
useSearch(currentOptions, searchQuery.value, currentValue.value, fieldTitle, fieldValue, filteredOptions, distinct);
143+
useSearch(
144+
currentOptions,
145+
searchQuery.value,
146+
currentValue.value,
147+
fieldTitle,
148+
fieldValue,
149+
filteredOptions,
150+
distinct,
151+
withNull,
152+
);
135153

136154
const setPrevActiveValue = () => {
137155
const node = filteredOptions.value.get(activeValue.value);

src/common/hooks/use-search.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const useSearch = (
99
fieldValue: string,
1010
filteredOptions: Ref<Map<any, any>>,
1111
distinct: boolean,
12+
withNull: boolean,
1213
) => {
1314
if (!searchString) {
1415
filteredOptions.value = new Map(JSON.parse(JSON.stringify([...input.value])));
@@ -23,7 +24,7 @@ export const useSearch = (
2324
let prev = null;
2425

2526
for (const item of input.value.values()) {
26-
if (item.id === null || item[fieldTitle] === null) {
27+
if (!withNull && (item.id === null || item[fieldTitle] === null)) {
2728
continue;
2829
}
2930

0 commit comments

Comments
 (0)