Skip to content

Commit

Permalink
Merge af87ad8 into 4523705
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Feb 27, 2023
2 parents 4523705 + af87ad8 commit 6587941
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/pro/search/src/composables/useSearchStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,22 @@ export function useSearchStates(
return false
}

const searchField = props.searchFields?.find(field => field.key === searchState.fieldKey)
// all valid segmentValue are not allowd to be undefined or null
// when current value isn't valid, return immediatly
if (!searchState.segmentValues.every(segmentValue => !isNil(segmentValue.value))) {
return false
}

const count = dataKeyCountMap.get(searchState.fieldKey)

// if there are more than one searchState of the same field key
// check whether mutiple searchState is allowed from the field config
if (count && count > (existed ? 1 : 0)) {
return !!searchField?.multiple
return !!props.searchFields?.find(field => field.key === searchState.fieldKey)?.multiple
}

return searchState.segmentValues.every(segmentValue => !isNil(segmentValue.value))
// all validations are passed
return true
}

const validateSearchState = (key: VKey) => {
Expand Down

0 comments on commit 6587941

Please sign in to comment.