From e3706094c24379fcba73c1e28ec538dbc18cf142 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 3 Feb 2025 12:03:39 +0100 Subject: [PATCH] fix: refs #8388 rollback --- src/components/common/VnSelect.vue | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index b24d38c97..339f90e0e 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -194,13 +194,14 @@ function setOptions(data) { function filter(val, options) { const search = val?.toString()?.toLowerCase(); + if (!search) return options; return options.filter((row) => { if ($props.filterOptions.length) { return $props.filterOptions.some((prop) => { const propValue = String(row[prop]).toLowerCase(); - return matchesSearch(propValue, search); + return propValue.includes(search); }); } @@ -208,17 +209,10 @@ function filter(val, options) { const id = String(row[$props.optionValue]); const optionLabel = String(row[$props.optionLabel]).toLowerCase(); - return matchesSearch(id, search) || optionLabel.includes(search); + return id.includes(search) || optionLabel.includes(search); }); } -function matchesSearch(val, search) { - return isDigit(search) ? val.startsWith(search) : val.includes(search); -} - -function isDigit(val) { - return /^\d+$/.test(val); -} async function fetchFilter(val) { if (!$props.url) return; @@ -287,9 +281,7 @@ function nullishToTrue(value) { return value ?? true; } -function getVal(val) { - return $props.useLike ? { like: isDigit(val) ? `${val}%` : `%${val}%` } : val; -} +const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val); async function onScroll({ to, direction, from, index }) { const lastIndex = myOptions.value.length - 1;