Skip to content

Commit

Permalink
fix(pro:search): segment should init only when it's set inactive (#1656)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 authored Aug 21, 2023
1 parent 97a40d6 commit 6ae11ea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
15 changes: 2 additions & 13 deletions packages/pro/search/src/ProSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import {
computed,
defineComponent,
nextTick,
normalizeClass,
normalizeStyle,
onMounted,
provide,
ref,
toRef,
watch,
} from 'vue'
import { computed, defineComponent, normalizeClass, normalizeStyle, onMounted, provide, ref, toRef, watch } from 'vue'

import { callEmit, convertCssPixel } from '@idux/cdk/utils'
import { ɵOverflow } from '@idux/components/_private/overflow'
Expand Down Expand Up @@ -107,7 +96,7 @@ export default defineComponent({
watch(
() => props.value,
() => {
nextTick(initSearchStates)
initSearchStates()
},
{ immediate: true, deep: true },
)
Expand Down
2 changes: 1 addition & 1 deletion packages/pro/search/src/composables/useSearchStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export function useSearchStates(
const segmentStates = generateSegmentStates(searchField, searchValue)

if (!segmentName) {
searchState.segmentStates = generateSegmentStates(searchField, searchValue)
searchState.segmentStates = segmentStates
} else {
const idx = searchState.segmentStates.findIndex(state => state.name === segmentName)
searchState.segmentStates[idx] = segmentStates[idx]
Expand Down
2 changes: 1 addition & 1 deletion packages/pro/search/src/composables/useSegmentStates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export function useSegmentStates(
watch(
[activeSegment, () => props.searchItem?.resolvedSearchField],
([activeSegment, searchField], [preActiveSegment]) => {
if (activeSegment?.itemKey === props.searchItem?.key) {
if (activeSegment?.itemKey === props.searchItem?.key || preActiveSegment?.itemKey !== props.searchItem?.key) {
return
}

Expand Down

0 comments on commit 6ae11ea

Please sign in to comment.