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(comp:cascader): selected and expanded status is display incorrectly #1386

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { type MergedData, convertMergedData, convertMergedDataMap } from './useD

export interface ExpandableContext {
expandedKeys: ComputedRef<VKey[]>
setExpandedKeys: (value: VKey[]) => void
handleExpand: (key: VKey) => void
loadingKeys: Ref<VKey[]>
}
Expand Down Expand Up @@ -104,5 +105,5 @@ export function useExpandable(
callChange(mergedDataMap, newKeys, onExpandedChange)
}

return { expandedKeys, handleExpand, loadingKeys }
return { expandedKeys, setExpandedKeys, handleExpand, loadingKeys }
}
10 changes: 8 additions & 2 deletions packages/components/cascader/src/contents/OverlayOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import { type PropType, Slot, computed, defineComponent, inject, normalizeClass } from 'vue'

import { isNil } from 'lodash-es'

import { IxCheckbox } from '@idux/components/checkbox'
import { convertIconVNode, useKey } from '@idux/components/utils'

Expand Down Expand Up @@ -35,9 +37,10 @@ export default defineComponent({
activeKey,
setActiveKey,
expandedKeys,
setExpandedKeys,
setOverlayOpened,
loadingKeys,
selectedKeys,
selectedWithStrategyKeys,
selectedLimit,
selectedLimitTitle,
indeterminateKeys,
Expand All @@ -48,7 +51,7 @@ export default defineComponent({
const isDisabled = computed(() => props.rawData.disabled)
const isExpanded = computed(() => expandedKeys.value.includes(key))
const isLoading = computed(() => loadingKeys.value.includes(key))
const isSelected = computed(() => selectedKeys.value.includes(key))
const isSelected = computed(() => selectedWithStrategyKeys.value.includes(key))
const isIndeterminate = computed(() => indeterminateKeys.value.includes(key))

const classes = computed(() => {
Expand All @@ -71,6 +74,9 @@ export default defineComponent({
}
handleSelect(key)
setOverlayOpened(false)

// 如果一级节点是叶子节点,被点击后关闭所有展开的节点。
isNil(props.parentKey) && setExpandedKeys([])
} else {
cascaderProps.strategy === 'off' && handleSelect(key)
cascaderProps.expandTrigger === 'click' && handleExpand(key)
Expand Down