Skip to content

fix TextBox multiline selection with up/down keys till start/end of text #18746

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 Apr 28, 2025

What does the pull request do?

Fix TextBox with multiline text during selection (Shift) with Up/Down keys

What is the current behavior?

In TextBox with multiline text while selecting (holding Shift):
pressing Down key on last line is not extending selection till the end of the last line text
pressing Up key on first line is not extending selection till the start of the first line text

What is the updated/expected behavior with this PR?

In TextBox with multiline text while selecting (holding Shift):
pressing Down key on last line will extend selection till the end of the last line text
pressing Up key on first line will extend selection till the start of the first line text

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

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@Gillibald
Copy link
Contributor

Gillibald commented Apr 28, 2025

You are changing public API. This can't be merged. The logic should also only expand the current selection to the end of the text when the current line is already added to the selection, and a second navigation in that direction is requested.

shiftSelection.mp4

@rastislavsvoboda
Copy link
Contributor Author

You are changing public API. This can't be merged. The logic should also only expand the current selection to the end of the text when the current line is already added to the selection, and a second navigation in that direction is requested.

shiftSelection.mp4

Hi Benedikt

I'm not sure what you try to show on video
can you please more describe what I should I see / not see?

if I create
public void MoveCaretVerticalWhileSelecting(LogicalDirection direction)
and leave original untouched
would this be ok for you?

tb_selection_fix.mp4

@Gillibald
Copy link
Contributor

The added logic to TextPresenter can be added to TextBox itself, so you do not need to add a isSelecting flag

@rastislavsvoboda
Copy link
Contributor Author

The added logic to TextPresenter can be added to TextBox itself, so you do not need to add a isSelecting flag

I've tried...

@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

@MrJul MrJul added the bug label Apr 30, 2025
@avaloniaui-bot
Copy link

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

@avaloniaui-bot
Copy link

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

Copy link
Contributor

@Gillibald Gillibald left a comment

Choose a reason for hiding this comment

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

LGTM

@Gillibald Gillibald added the backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch label May 20, 2025
@avaloniaui-bot
Copy link

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

@Gillibald Gillibald added this pull request to the merge queue May 25, 2025
Merged via the queue into AvaloniaUI:master with commit c114507 May 25, 2025
10 checks passed
MrJul pushed a commit that referenced this pull request Jun 5, 2025
…ext (#18746)

* fix: TextBox multiline selection with up/down keys till start/end of text

* refactor to preserve public API of TextPresenter

* refactor and cleanup
@MrJul MrJul added backported-11.3.x and removed backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels Jun 5, 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.

4 participants