Skip to content

Commit

Permalink
fix(tag-input): disabled reactive (Tencent#2406)
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn authored and methodchen committed Aug 25, 2023
1 parent 34f6085 commit 15be6fe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/select/option-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export default {
},
/** 选项值 */
value: {
type: [String, Number] as PropType<TdOptionProps['value']>,
type: [String, Number, Boolean] as PropType<TdOptionProps['value']>,
},
};
2 changes: 1 addition & 1 deletion src/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export default defineComponent({
collapsedSelectedItems: values
.map((item: any) => {
const tmpValue = typeof item === 'object' ? item[props.keys?.value || 'value'] : item;
return props.options.find((t: OptionData) => t.value === tmpValue);
return props.options?.find((t: OptionData) => t.value === tmpValue);
})
.slice(minCollapsedNum.value),
count: values.length - minCollapsedNum.value,
Expand Down
10 changes: 5 additions & 5 deletions src/tag-input/hooks/useHover.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ref, SetupContext } from '@vue/composition-api';
import { ref, SetupContext, Ref } from '@vue/composition-api';

export interface UseHoverParams {
readonly: boolean;
disabled: boolean;
readonly: Ref<boolean>;
disabled: Ref<boolean>;
onMouseenter: (context: { e: MouseEvent }) => void;
onMouseleave: (context: { e: MouseEvent }) => void;
}
Expand All @@ -14,14 +14,14 @@ export default function useHover(props: UseHoverParams, { emit }: SetupContext)
const isHover = ref<boolean>(false);

const addHover = (context: { e: MouseEvent }) => {
if (readonly || disabled) return;
if (readonly.value || disabled.value) return;
isHover.value = true;
onMouseenter?.(context);
emit('mouseenter', context);
};

const cancelHover = (context: { e: MouseEvent }) => {
if (readonly || disabled) return;
if (readonly.value || disabled.value) return;
isHover.value = false;
onMouseleave?.(context);
emit('mouseleave', context);
Expand Down
4 changes: 2 additions & 2 deletions src/tag-input/tag-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export default defineComponent({
} = toRefs(props);
const { isHover, addHover, cancelHover } = useHover(
{
readonly: props.readonly,
disabled: props.disabled,
readonly,
disabled,
onMouseenter: props.onMouseenter,
onMouseleave: props.onMouseleave,
},
Expand Down

0 comments on commit 15be6fe

Please sign in to comment.