Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input的clear清除问题 #840

Closed
xxyGoTop opened this issue Nov 1, 2019 · 3 comments
Closed

input的clear清除问题 #840

xxyGoTop opened this issue Nov 1, 2019 · 3 comments
Assignees
Labels
fixed but not released 已修复但未发布

Comments

@xxyGoTop
Copy link

xxyGoTop commented Nov 1, 2019

受控组件时,input点击clear按钮时,会触发onChange事件同时也会触发失焦事件里的onChange,此时e.detail.value获取到的依然是输入值的值而不是空,导致点击两次才会清空value

const [val, setVal] = useStae('')
// setVal是异步的
onChange = (value) => {
   setVal(value)
   return value
} 

组件源码问题

  onBlur = event => {
    this.props.onBlur(event.target.value, event)
    // fix # 583 AtInput 不触发 onChange 的问题
    this.props.onChange(event.target.value, event)
  }
@taro-ui-bot
Copy link

taro-ui-bot bot commented Nov 1, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@AwesomeDevin AwesomeDevin self-assigned this Dec 10, 2019
@AwesomeDevin AwesomeDevin added the fixed but not released 已修复但未发布 label Dec 10, 2019
@myNameIsDu
Copy link

还是没有解决呀

if (!event || event.type === 'input'){

只能这样做一下判断了

@pengtaoman
Copy link

private handleClearValue = (event: ITouchEvent): void => {
this.inputClearing = true
this.props.onChange?.('', event)
}

      {clear && value && (
        <View className='at-input__icon' onTouchEnd={this.handleClearValue}>
          <Text className='at-icon at-icon-close-circle at-input__icon-close'></Text>
        </View>
      )}

这段源码不生效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed but not released 已修复但未发布
Projects
None yet
Development

No branches or pull requests

4 participants