Skip to content

Commit

Permalink
fix(tree-select): 修复 valueDisplay 清空按钮不展示问题 (#1757)
Browse files Browse the repository at this point in the history
* fix(tree-select): 修复 valueDisplay 清空按钮不展示问题

fix #1743

* chore: update select demo

Co-authored-by: Uyarn <uyarnchen@gmail.com>
  • Loading branch information
honkinglin and uyarn authored Nov 30, 2022
1 parent 74379ca commit 339bac7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/select-input/useSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function useSingle(props: TdSelectInputProps) {
{...commonInputProps}
autoWidth={props.autoWidth}
placeholder={singleValueDisplay ? '' : props.placeholder}
value={singleValueDisplay ? undefined : displayedValue}
value={singleValueDisplay ? ' ' : displayedValue}
label={
<>
{props.label}
Expand Down
2 changes: 1 addition & 1 deletion src/select/_example/custom-selected.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const CustomSelected = () => {
clearable
defaultValue={'1'}
style={{ width: '300px', marginRight: '20px' }}
valueDisplay={({ value }) => `选中${value}`}
valueDisplay={({ value }) => (value ? `选中${value}` : null)}
>
{options.map((v, i) => (
<Select.Option value={v.value} key={i}>
Expand Down
24 changes: 16 additions & 8 deletions test/snap/__snapshots__/csr.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -69880,6 +69880,7 @@ exports[`csr snapshot test > csr test src/date-picker/_example/panel.jsx 1`] = `
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix t-input--suffix"
Expand All @@ -69894,7 +69895,7 @@ exports[`csr snapshot test > csr test src/date-picker/_example/panel.jsx 1`] = `
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
<span
class="t-input__suffix t-input__suffix-icon"
Expand Down Expand Up @@ -74527,6 +74528,7 @@ exports[`csr snapshot test > csr test src/date-picker/_example/panel.jsx 1`] = `
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix t-input--suffix"
Expand All @@ -74541,7 +74543,7 @@ exports[`csr snapshot test > csr test src/date-picker/_example/panel.jsx 1`] = `
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
<span
class="t-input__suffix t-input__suffix-icon"
Expand Down Expand Up @@ -157089,6 +157091,7 @@ exports[`csr snapshot test > csr test src/select/_example/custom-selected.jsx 1`
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix t-input--suffix"
Expand All @@ -157103,7 +157106,7 @@ exports[`csr snapshot test > csr test src/select/_example/custom-selected.jsx 1`
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
<span
class="t-input__suffix t-input__suffix-icon"
Expand Down Expand Up @@ -157218,6 +157221,7 @@ exports[`csr snapshot test > csr test src/select/_example/custom-selected.jsx 1`
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix t-input--suffix"
Expand All @@ -157232,7 +157236,7 @@ exports[`csr snapshot test > csr test src/select/_example/custom-selected.jsx 1`
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
<span
class="t-input__suffix t-input__suffix-icon"
Expand Down Expand Up @@ -163076,6 +163080,7 @@ exports[`csr snapshot test > csr test src/select-input/_example/custom-tag.jsx 1
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix"
Expand All @@ -163096,7 +163101,7 @@ exports[`csr snapshot test > csr test src/select-input/_example/custom-tag.jsx 1
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
</div>
</div>
Expand Down Expand Up @@ -163290,6 +163295,7 @@ exports[`csr snapshot test > csr test src/select-input/_example/custom-tag.jsx 1
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix"
Expand All @@ -163310,7 +163316,7 @@ exports[`csr snapshot test > csr test src/select-input/_example/custom-tag.jsx 1
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
</div>
</div>
Expand Down Expand Up @@ -261818,6 +261824,7 @@ exports[`csr snapshot test > csr test src/tree-select/_example/valuedisplay.jsx
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix t-input--suffix"
Expand All @@ -261832,7 +261839,7 @@ exports[`csr snapshot test > csr test src/tree-select/_example/valuedisplay.jsx
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
<span
class="t-input__suffix t-input__suffix-icon"
Expand Down Expand Up @@ -261968,6 +261975,7 @@ exports[`csr snapshot test > csr test src/tree-select/_example/valuedisplay.jsx
>
<div
class="t-input__wrap"
value=" "
>
<div
class="t-input t-is-readonly t-size-m t-align-left t-is-default t-input--prefix t-input--suffix"
Expand All @@ -261982,7 +261990,7 @@ exports[`csr snapshot test > csr test src/tree-select/_example/valuedisplay.jsx
placeholder=""
readonly=""
type="text"
value=""
value=" "
/>
<span
class="t-input__suffix t-input__suffix-icon"
Expand Down

0 comments on commit 339bac7

Please sign in to comment.