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

fix:keydown when keycode.enter,controlled inputnumber can't flush value #306

Merged
merged 3 commits into from Apr 14, 2021

Conversation

mankeheaven
Copy link
Contributor

@mankeheaven mankeheaven commented Mar 19, 2021

@vercel
Copy link

vercel bot commented Mar 19, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/input-number/6Q9VHWkCucx2Ua2ZzKPRF9MQfZeG
✅ Preview: https://input-number-git-fork-mankeheaven-305-react-component.vercel.app

@codecov
Copy link

codecov bot commented Mar 19, 2021

Codecov Report

Merging #306 (ec8b273) into master (6d956de) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head ec8b273 differs from pull request most recent head 35405fc. Consider uploading reports for the commit 35405fc to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
+ Coverage   97.25%   97.27%   +0.01%     
==========================================
  Files           8        8              
  Lines         401      403       +2     
  Branches      108      109       +1     
==========================================
+ Hits          390      392       +2     
  Misses         11       11              
Impacted Files Coverage Δ
src/InputNumber.tsx 98.19% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d956de...35405fc. Read the comment docs.

@yoyo837
Copy link
Member

yoyo837 commented Apr 1, 2021

能来个测试用例吗?

@mankeheaven
Copy link
Contributor Author

mankeheaven commented Apr 1, 2021

  it('pressEnter value should be ok', () => {
    const Demo = () => {
      const [value, setValue] = React.useState(1);
      return (
        <InputNumber
          value={value}
          onPressEnter={(e) => {
            setValue(e.target.value);
          }}
        />
      );
    };

    const wrapper = mount(<Demo />);
    wrapper.focusInput();
    wrapper.changeValue('3');
    wrapper.find('input').simulate('keyDown', { which: KeyCode.ENTER });
    expect(wrapper.getInputValue()).toEqual('3');
  });


ts在e.target.value这里出问题,不太清楚怎么写BaseSyntheticEvent这个里面,e.target是eventTarget类型,未能找到value属性

所以,是不是这个onpressEnter不能这么设置值?我打印是ok的,这个地方如何写泛型或者断言?能帮助一下我吗?

@mankeheaven
Copy link
Contributor Author

换了个方法,借用ref来拿值,ok了

@mankeheaven
Copy link
Contributor Author

这个pr没人处理吗?

@yoyo837
Copy link
Member

yoyo837 commented Apr 14, 2021

rebase 下

@mankeheaven
Copy link
Contributor Author

已经rebase

src/InputNumber.tsx Outdated Show resolved Hide resolved
@mankeheaven
Copy link
Contributor Author

再看看?

@zombieJ zombieJ merged commit 8890406 into react-component:master Apr 14, 2021
@zombieJ
Copy link
Member

zombieJ commented Apr 14, 2021

+ rc-input-number@7.0.6

@yoyo837
Copy link
Member

yoyo837 commented Apr 14, 2021

@mankeheaven 重装依赖试试看?

@mankeheaven
Copy link
Contributor Author

mankeheaven commented Apr 14, 2021

@yoyo837
antd的依赖更新?因为不是直接装的rc input number, 所以这个npm outdated看不出来, 是否需要antd也重新发包?不太清楚这两个发包的依赖影响?

@yoyo837
Copy link
Member

yoyo837 commented Apr 14, 2021

删除node_modules 和 lock文件重新安装

@mankeheaven
Copy link
Contributor Author

ok了,谢谢

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