Skip to content

Conversation

drasticactions
Copy link
Contributor

What does the pull request do?

Adds a new API to Calendar to allow tapping twice to select a range of dates.

What is the current behavior?

Date selection ranges are done using keyboard shortcuts, which does not work on mobile.

What is the updated/expected behavior with this PR?

This PR introduces a new AllowTapRangeSelection feature, enabling users to tap once to select an initial date and tap again to choose the second. It only works for SingleRange mode. If you have MultipleRange selected, it will work for the first range, then reset for the second.

I've added the boolean to preserve the existing keyboard functions for users who expect a new start date when clicking, ensuring the original functions remain intact. This is intended as a stopgap measure while we research different ways of handling more advance features in the future.

@avaloniaui-bot
Copy link

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

@MrJul MrJul added feature backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch needs-api-review The PR adds new public APIs that should be reviewed. labels Aug 1, 2025
@MrJul
Copy link
Member

MrJul commented Aug 11, 2025

API diff for review:

 namespace Avalonia.Controls
 {
     public class Calendar : TemplatedControl
     {
+        public static readonly StyledProperty<bool> AllowTapRangeSelectionProperty;
+        public bool AllowTapRangeSelection { get; set; }
     }
 }

@MrJul
Copy link
Member

MrJul commented Aug 12, 2025

The API is approved, but we want it true by default for range mode, because it's what users will be expecting while using the calendar with touch.

@MrJul MrJul added api-approved The new public APIs have been approved. and removed needs-api-review The PR adds new public APIs that should be reviewed. labels Aug 12, 2025
@MrJul
Copy link
Member

MrJul commented Aug 13, 2025

@drasticactions The AllowTapRangeSelection_Should_Enable_TapToSelectRange test needs to be updated following the default value change.

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!

@MrJul MrJul enabled auto-merge August 13, 2025 09:05
@avaloniaui-bot
Copy link

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

@MrJul MrJul added this pull request to the merge queue Aug 13, 2025
Merged via the queue into master with commit eff1c36 Aug 13, 2025
12 checks passed
@MrJul MrJul deleted the feature/calandar-tap-range branch August 13, 2025 13:00
MrJul pushed a commit that referenced this pull request Aug 15, 2025
* Add AllowTapRangeSelection for Calendar

* Fix spacing

* Let it be true...

* Update CalendarTests.cs
@MrJul MrJul added backported-11.3.x and removed backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels Aug 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved The new public APIs have been approved. backported-11.3.x feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants