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

Highlight pasted input #24

Merged
merged 7 commits into from Mar 23, 2019

Conversation

ivanross
Copy link
Contributor

@ivanross ivanross commented Mar 18, 2019

With this PR, when you paste something, the input pasted is highlighted.

This only works whit pasted input that has more than one char.

@ivanross ivanross marked this pull request as ready for review March 18, 2019 18:26
@vadimdemedes
Copy link
Owner

Hm, that's a bit unusual. What's it for?

@ivanross
Copy link
Contributor Author

I tried to simulate the common behaviour that occurs after pasting in terminal:

gif 1

This is the result with this PR:

gif 2

I thought this would be nice to have, but maybe there should be a prop to enable this?

src/index.js Outdated
@@ -49,7 +50,7 @@ class TextInput extends PureComponent {

let i = 0;
for (const char of value) {
if (i++ === cursorOffset) {
if (i >= cursorOffset - cursorWidth & i++ <= cursorOffset) {
Copy link
Owner

Choose a reason for hiding this comment

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

Could you add a comment with an explanation what and how is being calculated here? What's & for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry this is a mistake

@vadimdemedes
Copy link
Owner

Hm, never noticed it myself, you're right! Let's indeed expose it via a prop, disabled by default, since it would be a breaking change otherwise. We can reconsider the default value for the next major release ;)

@ivanross
Copy link
Contributor Author

Done, now there is a prop hightlightPasted. Default is false 💪

@vadimdemedes
Copy link
Owner

Could you rename it to highlightPastedText and document it in readme?

@ivanross
Copy link
Contributor Author

Done!!

@vadimdemedes
Copy link
Owner

Thank you, great addition!

@vadimdemedes vadimdemedes merged commit 85afe6a into vadimdemedes:master Mar 23, 2019
@ivanross ivanross deleted the highlight-pasted-input branch November 9, 2019 11:01
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.

None yet

2 participants