Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/components/select-input/useMultiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ export default function useMultiple(props: SelectInputProps) {
if (context?.trigger === 'enter' || context?.trigger === 'blur') return;
setTInputValue(val, { trigger: context.trigger, e: context.e });
}}
tagProps={props.tagProps}
onClear={p.onInnerClear}
// [Important Info]: SelectInput.blur is not equal to TagInput, example: click popup panel
onFocus={handleFocus}
onBlur={handleBlur}
{...props.tagInputProps}
tagProps={{ ...props.tagProps, ...props.tagInputProps?.tagProps }}
inputProps={{
...props.inputProps,
readOnly: !props.allowInput || readOnly,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/select/base/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const Select = forwardRefWithStatics(
panelTopContent,
selectInputProps,
tagInputProps,
tagProps,
scroll,
suffixIcon,
label,
Expand All @@ -102,6 +101,7 @@ const Select = forwardRefWithStatics(
onPopupVisibleChange,
} = props;
const readOnly = props.readOnly || props.readonly;
const tagProps = { ...props.tagProps, ...props.tagInputProps?.tagProps };

const [value, onChange] = useControlled(props, 'value', props.onChange);

Expand Down
6 changes: 5 additions & 1 deletion packages/components/tag-input/useTagList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,19 @@ export default function useTagList(props: TagInputProps) {
? [<Fragment key="display-node">{displayNode}</Fragment>]
: newList?.map((item, index) => {
const tagContent = isFunction(tag) ? tag({ value: item }) : tag;
const handleClose = (context) => {
tagProps?.onClose?.(context);
onClose({ e: context?.e, index });
};
return (
<Tag
key={index}
size={size}
disabled={disabled}
onClose={(context) => onClose({ e: context.e, index })}
closable={!readOnly && !disabled}
{...getDragProps?.(index, item)}
{...tagProps}
onClose={handleClose}
>
{tagContent ?? item}
</Tag>
Expand Down
7 changes: 4 additions & 3 deletions packages/components/tag/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const TagFunction: ForwardRefRenderFunction<HTMLDivElement, TagProps> = (
className,
);

const TagCloseIcon = () => {
const tagCloseIcon = useMemo(() => {
const iconNode = tagConfig?.closeIcon ? tagConfig.closeIcon : <CloseIcon />;
if (React.isValidElement(iconNode)) {
const element = iconNode as React.ReactElement<any>;
Expand All @@ -84,7 +84,8 @@ export const TagFunction: ForwardRefRenderFunction<HTMLDivElement, TagProps> = (
className: classNames(element.props?.className, `${tagClassPrefix}__icon-close`),
});
}
};
return null;
}, [CloseIcon, disabled, tagClassPrefix, tagConfig.closeIcon, onClose]);

const title = useMemo(() => {
if (Reflect.has(props, 'title')) return titleAttr;
Expand Down Expand Up @@ -143,7 +144,7 @@ export const TagFunction: ForwardRefRenderFunction<HTMLDivElement, TagProps> = (
<span className={maxWidth ? `${tagClassPrefix}--text` : undefined} style={getTextStyle} {...titleAttribute}>
{children ?? content}
</span>
{closable && !disabled && <TagCloseIcon />}
{closable && !disabled && tagCloseIcon}
</>
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions packages/tdesign-react/.changelog/pr-4070.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
pr_number: 4070
contributor: RylanBot
---

- fix(SelectInput): 修复 `1.16.0` 版本的修复导致点击 `closable` 图标时无法清除选项的问题 @RylanBot ([#4070](https://github.com/Tencent/tdesign-react/pull/4070))
- fix(SelectInput): 修复传入 `tagInputProps.tagProps.onClose` 时,`onTagChange` 不生效的问题 @RylanBot ([#4070](https://github.com/Tencent/tdesign-react/pull/4070))
- fix(Select): 修复 `tagInputProps.tagProps` 不生效的问题 @RylanBot ([#4070](https://github.com/Tencent/tdesign-react/pull/4070))
Loading