ant-design / ant-design-mobile

Essential UI blocks for building mobile web apps.
https://mobile.ant.design
MIT License
11.51k stars 2.38k forks source link

feat: `TextArea` add `setSelectionRange ` #6522

Closed susiwen8 closed 5 months ago

susiwen8 commented 6 months ago

Background: In my project, there is a need to insert some characters into a textarea using JavaScript. Currently, the TextArea component doesn't provide the setSelectionRange method, which results in the cursor not being positioned after the inserted characters. This leads to a poor user input experience. Therefore, in this PR, I have added this method.

github-actions[bot] commented 6 months ago

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-6522.surge.sh

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (b431a18) 92.27% compared to head (a4e639a) 92.27%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #6522 +/- ## ======================================= Coverage 92.27% 92.27% ======================================= Files 316 316 Lines 6897 6899 +2 Branches 1728 1729 +1 ======================================= + Hits 6364 6366 +2 Misses 497 497 Partials 36 36 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

zombieJ commented 5 months ago

Why not ref.current.nativeElement.setSelectionRange?

susiwen8 commented 5 months ago

Why not ref.current.nativeElement.setSelectionRange?

Right, that works too!