Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pro:search): search states should update when field changes #1662

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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