Skip to content

Commit

Permalink
fix(pro:search): search states should update when field changes (#1662)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 committed Aug 28, 2023
1 parent 01f0d0e commit a564dd3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/pro/search/src/composables/useSegmentStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,18 +174,26 @@ export function useSegmentStates(
}

watch(
[activeSegment, () => props.searchItem?.resolvedSearchField],
([activeSegment, searchField], [preActiveSegment]) => {
() => props.searchItem?.resolvedSearchField,
() => {
initSearchState(props.searchItem!.key)
},
)
watch(
activeSegment,
(activeSegment, preActiveSegment) => {
if (activeSegment?.itemKey === props.searchItem?.key || preActiveSegment?.itemKey !== props.searchItem?.key) {
return
}

const searchField = props.searchItem?.resolvedSearchField

if (!searchField) {
initSearchState(props.searchItem!.key)
return
}

const preSegment = props.searchItem?.resolvedSearchField.segments.find(seg => seg.name === preActiveSegment?.name)
const preSegment = searchField.segments.find(seg => seg.name === preActiveSegment?.name)

// if current segment has no panel and the whole search item is valid after input
// then update search values
Expand Down

0 comments on commit a564dd3

Please sign in to comment.