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(InputItem): add try catch to setSelection (#3120) #3124

Merged
merged 2 commits into from
Mar 21, 2019

Conversation

zack24q
Copy link
Contributor

@zack24q zack24q commented Mar 20, 2019

First of all, thank you for your contribution! :-)

Please makes sure that these checkboxes are checked before submitting your PR, thank you!

  • Make sure that you follow antd's code convention.
  • Run npm run lint and fix those errors before submitting in order to keep consistent code style.
  • Rebase before creating a PR to keep commit history clear.
  • Add some descriptions and refer relative issues for you PR.

Extra checklist:

if isBugFix :

  • Make sure that you add at least one unit test for the bug which you had fixed.

elif isNewFeature :

  • Update API docs for the component.
  • Update/Add demo to demonstrate new feature.
  • Update TypeScript definition for the component.
  • Add unit tests for the feature.

This change is Reviewable

@zack24q zack24q requested a review from doxiaodong March 20, 2019 01:43
@ghost ghost assigned zack24q Mar 20, 2019
@ghost ghost added the In Progress label Mar 20, 2019
@doxiaodong
Copy link
Contributor

从根源上解决error

@codecov
Copy link

codecov bot commented Mar 20, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@3111700). Click here to learn what that means.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #3124   +/-   ##
=========================================
  Coverage          ?   60.24%           
=========================================
  Files             ?       92           
  Lines             ?     2269           
  Branches          ?      651           
=========================================
  Hits              ?     1367           
  Misses            ?      893           
  Partials          ?        9
Flag Coverage Δ
#web 60.24% <66.66%> (?)
Impacted Files Coverage Δ
components/input-item/index.tsx 65.13% <66.66%> (ø)

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 3111700...6e79781. Read the comment docs.

@zack24q
Copy link
Contributor Author

zack24q commented Mar 20, 2019

根本原因是一些老内核下,有一些input type不支持selection api,所以这边catch住之后就做降级处理,不对光标做位置计算,回归老逻辑
兼容性参考链接:https://developer.mozilla.org/zh-CN/docs/Web/API/HTMLInputElement/setSelectionRange#%E6%B5%8F%E8%A7%88%E5%99%A8%E5%85%BC%E5%AE%B9%E6%80%A7

@doxiaodong
Copy link
Contributor

https://github.com/ant-design/ant-design-mobile/pull/3124/files#diff-da561ee58a9d0bf6841793d9067364a5R219
我的意思是这一个行数没发现哪个会抛出 error

@zack24q
Copy link
Contributor Author

zack24q commented Mar 20, 2019

相关issue #3120
selectionStartselectionEnd 赋值可能会抛出error的

Copy link
Contributor

@doxiaodong doxiaodong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doxiaodong doxiaodong merged commit 05b9d86 into master Mar 21, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix-input-item-selection-error branch March 21, 2019 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants