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

Stepper 组件在Chrome中onChange有问题 #891

Closed
Here21 opened this issue Feb 25, 2017 · 8 comments · Fixed by react-component/input-number#50
Closed

Stepper 组件在Chrome中onChange有问题 #891

Here21 opened this issue Feb 25, 2017 · 8 comments · Fixed by react-component/input-number#50
Assignees
Labels

Comments

@Here21
Copy link

Here21 commented Feb 25, 2017

Environment(required)

  • antd-mobile version: v1.0.0
  • Browser (or mark react-native) and its version: Chrome版本 56.0.2924.87 (64-bit)
  • Operating environment (e.g. OS name) and its version: macOS 10.12.3

What did you do? Please provide steps to re-produce your problem.

在公司项目中,使用了最新的 antd-mobile@1.0.0 ,demo中使用Stepper组件出现的问题

What do you expected?

预期:按增加或者减少按钮,增加/减少 1

What happen?

实际:按下按钮单次增加/减少2,onChange会出发两次,在按下和抬起各执行一次。

Re-producible online demo

是公司项目在使用,所以只能提供该源代码:

import React, { Component } from 'react'
import { Card, Stepper } from 'antd-mobile/dist/antd-mobile';
import './style.css'

class RowCard extends Component {
  constructor(props) {
    super(props)
    this.state = {
      value: 3
    }
  }

  onChange(val) {
    console.log('val is :' + val)
    this.setState({ value: val });
  }

  render() {
    // console.log(this.state.value)
    return (
      <div>
        <Card full>
          <Card.Header
            title={
              <div className="card-middle" style={{ width: '3rem' }}>
                <p className="card-middle-name">demo</p>
                <p className="card-middle-sauce">demo</p>
                <p className="card-middle-price">¥38</p>
              </div>
            }
            thumb="https://cloud.githubusercontent.com/assets/1698185/18039916/f025c090-6dd9-11e6-9d86-a4d48a1bf049.png"
            thumbStyle={{ width: '1.8rem' }}
            extra={
              <Stepper
                style={{ width: '2rem' }}
                showNumber
                max={99}
                min={0}
                step="1"
                value={this.state.value}
                onChange={::this.onChange}
              />
            }
          />
        </Card>
      </div>
    )
  }
}

export default RowCard

bug

@paranoidjk
Copy link
Contributor

刚试了我这边没复现,官网demo也没问题,确认你的版本?

请给我们一个可重现的在线demo吧,便于定位问题 https://codepen.io/warmhug/pen/bwRPvx 谢谢

@Here21
Copy link
Author

Here21 commented Feb 25, 2017

这是一个基于Meteor的项目,暂时还没独立服务器,提供源代码可以吗?
这个问题只在Chrome 设备模拟器条件下才有,普通调试正常,Safari并没有出现这个问题。

Chrome toggle device toolbar :
Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/5093566007214080

@paranoidjk
Copy link
Contributor

https://mobile.ant.design/kitchen-sink/ 一直都是在chrome模拟器下调试

没法重现我这边没法帮你,在codepen上给一个重现demo就好了,参考我上面发你的链接

@paranoidjk
Copy link
Contributor

另外,check你的版本,最新1.0.1

@Here21
Copy link
Author

Here21 commented Feb 25, 2017

问题类似:
#785

@paranoidjk
Copy link
Contributor

关联 react-component/input-number#48

这个bug只在chrome模拟器下有,真是环境真机和pc都不会有

@silentcloud
Copy link
Contributor

silentcloud commented Feb 28, 2017

mobile 的代码优先在真机上做测试

@Here21
Copy link
Author

Here21 commented Feb 28, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants