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

Backspace misbehavior in wrapped textarea #313

Closed
ExoticMatter opened this issue May 16, 2022 · 6 comments
Closed

Backspace misbehavior in wrapped textarea #313

ExoticMatter opened this issue May 16, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@ExoticMatter
Copy link

When a textarea contains wrapped text, backspace causes the caret to move to the left, as if the left arrow key was pressed immediately after pressing backspace. Every prior wrapped line causes the caret to move left an additional extra character.

Example text (text is one single line; each string of characters is separated by a space to allow wrapping; | represents the caret)

aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaabcd|

After pressing backspace:

...aaaaaaa|abc

(redundant text omitted for brevity)

@mikke89
Copy link
Owner

mikke89 commented May 16, 2022

Thanks for the well written report, I am able to replicate this on my end.

I found that this also occurs if we select some text on a soft-wrapped line and then move the caret left or right. I will look into it.

@mikke89 mikke89 added the bug Something isn't working label May 16, 2022
@ExoticMatter
Copy link
Author

I was previously under the impression that the delete key didn't cause the caret to move left after a wrapped line, but it in fact does.

mikke89 added a commit that referenced this issue May 20, 2022
… fix issues related to the cursor being off-by-n with word wrapping enabled. See #313.
@mikke89
Copy link
Owner

mikke89 commented May 20, 2022

Text editing is quite tricky it turns out. But I've made an effort to fix this. I had to refactor a bit, trying to simplify things, because it was very hard to follow the old code with a lot of duplicate state.

I may have accidently introduced new bugs with these changes, because text editing is tricky. Could you test the changes I made in the textarea branch, see if it fixes the issue and try to break everything and discover any new (or old) bugs?

@ExoticMatter
Copy link
Author

It has fixed the issue, and I haven't found any new problems with the patch so far (or old problems, for that matter.)

mikke89 added a commit that referenced this issue May 22, 2022
- Simplify and remove duplicate cursor state.
- The widget's text synchronizes with the element's value attribute.
- A sanitization step removes invalid characters for the given text field type.
- A separate transformation can be applied which is purely visual, mainly for password fields.

This fixes issues such as:
- Cursor being off-by-n with word wrapping enabled (see #313).
- Windows endlines (\r\n) being displayed with an extra space.
- Putting invalid characters (e.g. \t) in a text input's value attribute would make the cursor and text editing apply to a wrong location in the text.
- Data bindings are now updated to reflect the sanitized value.
@mikke89
Copy link
Owner

mikke89 commented May 22, 2022

I've been working more on the text widget. I discovered some issues introduced with the previous changes, mainly to do with password fields.

In any case, I've made a lot of improvements since then, both quality-of-life improvements, fixing small issues, and code cleanup. See the commit messages for details: https://github.com/mikke89/RmlUi/commits/textarea.

I'm re-opening this for some time so that people can be aware of these changes and report any related issues or other feedback.

@mikke89 mikke89 reopened this May 22, 2022
@mikke89
Copy link
Owner

mikke89 commented Jun 22, 2022

I added some additional fixes and changes some commits back. I haven't seen any new issues in a while so I'm closing this one for now. Please open a new issue if you do find any related ones.

@mikke89 mikke89 closed this as completed Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants