Skip to content

TextBox: clear selection when moving the caret horizontally #18255

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

Conversation

rastislavsvoboda
Copy link
Contributor

@rastislavsvoboda rastislavsvoboda commented Feb 19, 2025

What does the pull request do?

fix clearing selection on TextBox when left/right arrow key is pressed

What is the current behavior?

when there is selection in TextBox, and
selection starts on left, pressing left arrow key does not clear selection
selection starts on right, pressing right arrow key does not clear selection

What is the updated/expected behavior with this PR?

pressing left/right arrow key clears the selection, moving caret to appropriate side of the previous selection

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0054996-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added the bug label Feb 20, 2025
Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

Unfortunately, the fix isn't quite right. It changes the caret position unexpectedly for all other cases: select a few chars left-to-right, press the right arrow, and notice that the caret is now incorrectly to the left of the selection (and vice versa for a right-to-left with the left arrow).

Moreover, some matching unit tests would be greatly appreciated.

@MrJul MrJul added the backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch label Feb 21, 2025
Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@MrJul MrJul enabled auto-merge February 21, 2025 15:31
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.3.999-cibuild0055024-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added this pull request to the merge queue Feb 21, 2025
Merged via the queue into AvaloniaUI:master with commit 939c780 Feb 21, 2025
11 checks passed
MrJul pushed a commit that referenced this pull request Feb 28, 2025
* TextBox: clear selection when moving the caret horizontally

* fix and add unit tests
@MrJul MrJul added backported-11.2.x and removed backport-candidate-11.2.x Consider this PR for backporting to 11.2 branch labels Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants