Skip to content

Commit

Permalink
fix(select): autoWidth in multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Aug 12, 2022
1 parent d34e99b commit abc9a91
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 40 deletions.
2 changes: 1 addition & 1 deletion site/site.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export default {
component: () => import('tdesign-react/image/image.md'),
},
{
title: 'ImageViewer 图片',
title: 'ImageViewer 图片预览',
name: 'image-viewer',
path: '/react/components/image-viewer',
component: () => import('tdesign-react/image-viewer/image-viewer.md'),
Expand Down
1 change: 0 additions & 1 deletion src/cascader/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ const Cascader = (props: CascaderProps) => {
}}
inputProps={{ size: props.size, ...(props.inputProps as TdCascaderProps['inputProps']) }}
tagInputProps={{
autoWidth: true,
size: props.size,
...(props.tagInputProps as TdCascaderProps['tagInputProps']),
}}
Expand Down
12 changes: 12 additions & 0 deletions src/collapse/__tests__/__snapshots__/collapse.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ exports[`base.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -534,6 +537,9 @@ exports[`icon.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -812,6 +818,9 @@ exports[`mutex.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
</div>
</div>
</div>
Expand Down Expand Up @@ -1003,6 +1012,9 @@ exports[`other.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ exports[`text.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
</div>
</div>
<span
Expand Down
22 changes: 19 additions & 3 deletions src/input/__tests__/__snapshots__/input.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -750,10 +750,9 @@ exports[`size.jsx 1`] = `
>
<div
class="t-input__wrap"
value=""
>
<div
class="t-input t-size-l t-align-left t-is-default"
class="t-input t-size-s t-align-left t-is-default"
>
<input
class="t-input__inner"
Expand All @@ -769,7 +768,6 @@ exports[`size.jsx 1`] = `
>
<div
class="t-input__wrap"
value=""
>
<div
class="t-input t-size-m t-align-left t-is-default"
Expand All @@ -783,6 +781,24 @@ exports[`size.jsx 1`] = `
</div>
</div>
</div>
<div
class="t-space-item"
>
<div
class="t-input__wrap"
>
<div
class="t-input t-size-l t-align-left t-is-default"
>
<input
class="t-input__inner"
placeholder="请输入内容"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</DocumentFragment>
`;
Expand Down
12 changes: 10 additions & 2 deletions src/input/_example/size.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { Input, Space } from 'tdesign-react';

export default function InputExample() {
const [value, onChange] = useState('');
const [value, onChange] = useState(null);
return (
<Space direction="vertical" style={{ width: 500 }}>
<Input
Expand All @@ -11,7 +11,7 @@ export default function InputExample() {
onChange={(value) => {
onChange(value);
}}
size="large"
size="small"
/>
<Input
placeholder="请输入内容"
Expand All @@ -20,6 +20,14 @@ export default function InputExample() {
onChange(value);
}}
/>
<Input
placeholder="请输入内容"
value={value}
onChange={(value) => {
onChange(value);
}}
size="large"
/>
</Space>
);
}
1 change: 0 additions & 1 deletion src/select/base/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ const Select = forwardRefWithStatics(
placeholder={!multiple && showPopup && selectedLabel ? selectedLabel : placeholder || t(local.placeholder)}
inputValue={inputValue}
tagInputProps={{
autoWidth: true,
...tagInputProps,
}}
tagProps={tagProps}
Expand Down
2 changes: 1 addition & 1 deletion src/table/__tests__/__snapshots__/table.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5413,7 +5413,7 @@ exports[`editable-row.jsx 1`] = `
class="t-select t-select-input t-select-input--multiple"
>
<div
class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input__with-suffix-icon"
class="t-input__wrap t-tag-input t-tag-input--break-line t-tag-input__with-suffix-icon t-input--auto-width"
value=""
>
<div
Expand Down
4 changes: 2 additions & 2 deletions src/tag-input/TagInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const TagInput = forwardRef((props: TagInputProps, ref) => {
onChange={(val, context) => {
setTInputValue(val, { ...context, trigger: 'input' });
}}
autoWidth={autoWidth}
autoWidth={true} // 控制input_inner的宽度 设置为true让内部input不会提前换行
onWheel={onWheel}
size={size}
readonly={readonly}
Expand All @@ -144,7 +144,7 @@ const TagInput = forwardRef((props: TagInputProps, ref) => {
suffix={suffix}
suffixIcon={suffixIconNode}
showInput={!inputProps?.readonly || !tagValue || !tagValue?.length}
keepWrapperWidth={true}
keepWrapperWidth={!autoWidth}
onPaste={onPaste}
onClick={onInnerClick}
onEnter={onInputEnter}
Expand Down
20 changes: 20 additions & 0 deletions src/tree-select/__tests__/__snapshots__/tree-select.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ exports[`collapsed.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
<span
class="t-input__suffix t-input__suffix-icon"
>
Expand Down Expand Up @@ -169,6 +172,9 @@ exports[`collapsed.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
<span
class="t-input__suffix t-input__suffix-icon"
>
Expand Down Expand Up @@ -316,6 +322,11 @@ exports[`filterable.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
>
请选择
</span>
<span
class="t-input__suffix t-input__suffix-icon"
>
Expand Down Expand Up @@ -453,6 +464,9 @@ exports[`multiple.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
<span
class="t-input__suffix t-input__suffix-icon"
>
Expand Down Expand Up @@ -700,6 +714,9 @@ exports[`valuedisplay.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
<span
class="t-input__suffix t-input__suffix-icon"
>
Expand Down Expand Up @@ -838,6 +855,9 @@ exports[`valuetype.jsx 1`] = `
type="text"
value=""
/>
<span
class="t-input__input-pre"
/>
<span
class="t-input__suffix t-input__suffix-icon"
>
Expand Down
56 changes: 28 additions & 28 deletions test/ssr/__snapshots__/ssr.test.js.snap

Large diffs are not rendered by default.

0 comments on commit abc9a91

Please sign in to comment.