Skip to content

Commit

Permalink
fix: transfer handleClear not work
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed May 18, 2018
1 parent d148108 commit 4582da3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports[`renders ./components/locale-provider/demo/all.md correctly 1`] = `
</div>
<div class="ant-transfer-list-body ant-transfer-list-body-with-search">
<div class="ant-transfer-list-body-search-wrapper">
<div handleClear="function () { [native code] }">
<div>
<input value="" placeholder="Search here" type="text" class="ant-input ant-transfer-list-search ant-transfer-list-search"><span class="ant-transfer-list-search-action"><i class="anticon anticon-search"></i></span></div>
</div>
<div class="ant-transfer-list-content-warp"></div>
Expand All @@ -94,7 +94,7 @@ exports[`renders ./components/locale-provider/demo/all.md correctly 1`] = `
</div>
<div class="ant-transfer-list-body ant-transfer-list-body-with-search">
<div class="ant-transfer-list-body-search-wrapper">
<div handleClear="function () { [native code] }">
<div>
<input value="" placeholder="Search here" type="text" class="ant-input ant-transfer-list-search ant-transfer-list-search"><span class="ant-transfer-list-search-action"><i class="anticon anticon-search"></i></span></div>
</div>
<div class="ant-transfer-list-content-warp"></div>
Expand Down
8 changes: 4 additions & 4 deletions components/transfer/__tests__/__snapshots__/demo.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exports[`renders ./components/transfer/demo/advanced.md correctly 1`] = `
</div>
<div class="ant-transfer-list-body ant-transfer-list-body-with-search">
<div class="ant-transfer-list-body-search-wrapper">
<div handleClear="function () { [native code] }">
<div>
<input value="" placeholder="Search here" type="text" class="ant-input ant-transfer-list-search ant-transfer-list-search"><span class="ant-transfer-list-search-action"><i class="anticon anticon-search"></i></span></div>
</div>
<div class="ant-transfer-list-content-warp"></div>
Expand All @@ -34,7 +34,7 @@ exports[`renders ./components/transfer/demo/advanced.md correctly 1`] = `
</div>
<div class="ant-transfer-list-body ant-transfer-list-body-with-search">
<div class="ant-transfer-list-body-search-wrapper">
<div handleClear="function () { [native code] }">
<div>
<input value="" placeholder="Search here" type="text" class="ant-input ant-transfer-list-search ant-transfer-list-search"><span class="ant-transfer-list-search-action"><i class="anticon anticon-search"></i></span></div>
</div>
<div class="ant-transfer-list-content-warp"></div>
Expand Down Expand Up @@ -183,7 +183,7 @@ exports[`renders ./components/transfer/demo/search.md correctly 1`] = `
</div>
<div class="ant-transfer-list-body ant-transfer-list-body-with-search">
<div class="ant-transfer-list-body-search-wrapper">
<div handleClear="function () { [native code] }">
<div>
<input value="" placeholder="Search here" type="text" class="ant-input ant-transfer-list-search ant-transfer-list-search"><span class="ant-transfer-list-search-action"><i class="anticon anticon-search"></i></span></div>
</div>
<div class="ant-transfer-list-content-warp"></div>
Expand All @@ -205,7 +205,7 @@ exports[`renders ./components/transfer/demo/search.md correctly 1`] = `
</div>
<div class="ant-transfer-list-body ant-transfer-list-body-with-search">
<div class="ant-transfer-list-body-search-wrapper">
<div handleClear="function () { [native code] }">
<div>
<input value="" placeholder="Search here" type="text" class="ant-input ant-transfer-list-search ant-transfer-list-search"><span class="ant-transfer-list-search-action"><i class="anticon anticon-search"></i></span></div>
</div>
<div class="ant-transfer-list-content-warp"></div>
Expand Down
9 changes: 6 additions & 3 deletions components/transfer/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const TransferSearchProps = {
prefixCls: PropTypes.string,
placeholder: PropTypes.string,
value: PropTypes.any,
handleClear: PropTypes.func,
}

export default {
Expand All @@ -18,15 +19,17 @@ export default {
handleChange (e) {
this.$emit('change', e)
},
handleClear (e) {
handleClear2 (e) {
e.preventDefault()
this.$emit('handleClear', e)
if (this.handleClear) {
this.handleClear(e)
}
},
},
render () {
const { placeholder, value, prefixCls } = getOptionProps(this)
const icon = (value && value.length > 0) ? (
<a href='#' class={`${prefixCls}-action`} onClick={this.handleClear}>
<a href='#' class={`${prefixCls}-action`} onClick={this.handleClear2}>
<Icon type='cross-circle' />
</a>
) : (
Expand Down

0 comments on commit 4582da3

Please sign in to comment.