Skip to content

Commit

Permalink
fix(input,selectinput): type类型问题及key重复问题
Browse files Browse the repository at this point in the history
  • Loading branch information
carolin913 committed Mar 21, 2022
1 parent 9f51f42 commit 0041f9e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/checkbox/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ export function CheckboxGroup(props: CheckboxGroupProps) {
case 'string': {
const vs = v as string;
return (
<Checkbox key={vs} label={vs} value={vs}>
<Checkbox key={index} label={vs} value={vs}>
{v}
</Checkbox>
);
}
case 'number': {
const vs = v as number;
return (
<Checkbox key={vs} label={vs} value={vs}>
<Checkbox key={index} label={vs} value={vs}>
{v}
</Checkbox>
);
Expand All @@ -152,7 +152,7 @@ export function CheckboxGroup(props: CheckboxGroupProps) {
return vs.checkAll ? (
<Checkbox {...v} key={`checkAll_${index}`} indeterminate={indeterminate} />
) : (
<Checkbox {...v} key={vs.value} disabled={vs.disabled || disabled} />
<Checkbox {...v} key={index} disabled={vs.disabled || disabled} />
);
}
default:
Expand Down
8 changes: 4 additions & 4 deletions src/input/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,23 +141,23 @@ export interface TdInputProps {
/**
* 回车键按下时触发
*/
onEnter?: (value: InputValue, context: { e: KeyboardEvent<HTMLDivElement> }) => void;
onEnter?: (value: InputValue, context: { e: KeyboardEvent<HTMLInputElement> }) => void;
/**
* 获得焦点时触发
*/
onFocus?: (value: InputValue, context: { e: FocusEvent<HTMLInputElement> }) => void;
/**
* 键盘按下时触发
*/
onKeydown?: (value: InputValue, context: { e: KeyboardEvent<HTMLDivElement> }) => void;
onKeydown?: (value: InputValue, context: { e: KeyboardEvent<HTMLInputElement> }) => void;
/**
* 按下字符键时触发(keydown -> keypress -> keyup)
*/
onKeypress?: (value: InputValue, context: { e: KeyboardEvent<HTMLDivElement> }) => void;
onKeypress?: (value: InputValue, context: { e: KeyboardEvent<HTMLInputElement> }) => void;
/**
* 释放键盘时触发
*/
onKeyup?: (value: InputValue, context: { e: KeyboardEvent<HTMLDivElement> }) => void;
onKeyup?: (value: InputValue, context: { e: KeyboardEvent<HTMLInputElement> }) => void;
/**
* 进入输入框时触发
*/
Expand Down
3 changes: 3 additions & 0 deletions src/select-input/useSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export default function useSingle(props: TdSelectInputProps) {
props.onFocus?.(value, { ...context, inputValue: val });
!popupVisible && setInputValue(getInputValue(value, keys), { ...context, trigger: 'input' });
}}
onEnter={(val, context) => {
props.onEnter?.(value, { ...context, inputValue: val });
}}
{...props.inputProps}
className={classNames(props.inputProps?.className, {
[`${classPrefix}-input--focused`]: popupVisible,
Expand Down
2 changes: 1 addition & 1 deletion src/tag-input/useTagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function useTagList(props: TagInputProps) {
const tagContent = isFunction(tag) ? tag({ value: item }) : tag;
return (
<Tag
key={item}
key={index}
size={size}
disabled={disabled}
onClose={(context) => onClose({ e: context.e, item, index })}
Expand Down

0 comments on commit 0041f9e

Please sign in to comment.