Skip to content

Commit

Permalink
fix(taro-components): textarea event handler miss pass detail value
Browse files Browse the repository at this point in the history
textarea onFocus & onBlur event handler miss pass detail value
  • Loading branch information
pacoyang committed Jan 14, 2019
1 parent 6cfa200 commit 08221f6
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions packages/taro-components/src/components/textarea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class Textarea extends Nerv.Component {
constructor () {
super(...arguments)
this.onChange = this.onChange.bind(this)
this.onFocus = this.onFocus.bind(this)
this.onBlur = this.onBlur.bind(this)
}

onChange (e) {
Expand All @@ -18,14 +20,34 @@ class Textarea extends Nerv.Component {
if (onInput) return onInput && onInput(e)
}

onFocus (e) {
const { onFocus } = this.props
Object.defineProperty(e, 'detail', {
enumerable: true,
value: {
value: e.target.value
}
})
onFocus && onFocus(e)
}

onBlur (e) {
const { onBlur } = this.props
Object.defineProperty(e, 'detail', {
enumerable: true,
value: {
value: e.target.value
}
})
onBlur && onBlur(e)
}

render () {
const {
className = '',
placeholder = '',
disabled,
maxlength = 140,
onFocus,
onBlur,
autoFocus = false
} = this.props
return (
Expand All @@ -47,8 +69,8 @@ class Textarea extends Nerv.Component {
maxlength={maxlength}
autofocus={autoFocus}
onChange={this.onChange}
onFocus={onFocus}
onBlur={onBlur}
onFocus={this.onFocus}
onBlur={this.onBlur}
/>
)
}
Expand Down

0 comments on commit 08221f6

Please sign in to comment.