Skip to content

Commit

Permalink
fix(comp:time-picker): range with empty array shouldn't be clearable (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 authored Dec 23, 2022
1 parent 14637be commit e6800a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { ɵTriggerProps } from '@idux/components/_private/trigger'

import { type ComputedRef, computed } from 'vue'

import { isArray } from 'lodash-es'

export function useTriggerProps(context: DatePickerContext | DateRangePickerContext): ComputedRef<ɵTriggerProps> {
const {
props,
Expand Down Expand Up @@ -39,7 +41,11 @@ export function useTriggerProps(context: DatePickerContext | DateRangePickerCont
return computed(() => {
return {
borderless: props.borderless,
clearable: !props.readonly && !accessor.disabled && (props.clearable ?? config.clearable) && !!accessor.value,
clearable:
!props.readonly &&
!accessor.disabled &&
(props.clearable ?? config.clearable) &&
(isArray(accessor.value) ? !!accessor.value.length : !!accessor.value),
clearIcon: props.clearIcon ?? config.clearIcon,
disabled: accessor.disabled,
focused: isFocused.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { ɵTriggerProps } from '@idux/components/_private/trigger'

import { type ComputedRef, computed } from 'vue'

import { isArray } from 'lodash-es'

import { TimePickerContext, TimeRangePickerContext } from '../tokens'

export function useTriggerProps(context: TimePickerContext | TimeRangePickerContext): ComputedRef<ɵTriggerProps> {
Expand Down Expand Up @@ -39,7 +41,11 @@ export function useTriggerProps(context: TimePickerContext | TimeRangePickerCont

return computed(() => ({
borderless: props.borderless,
clearable: !props.readonly && !accessor.disabled && (props.clearable ?? config.clearable) && !!accessor.value,
clearable:
!props.readonly &&
!accessor.disabled &&
(props.clearable ?? config.clearable) &&
(isArray(accessor.value) ? !!accessor.value.length : !!accessor.value),
clearIcon: props.clearIcon ?? config.clearIcon,
disabled: accessor.disabled,
focused: isFocused.value,
Expand Down

0 comments on commit e6800a7

Please sign in to comment.