Skip to content

feat(date-picker): add date range picker #606 #823

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MerlinMoos
Copy link
Contributor

@MerlinMoos MerlinMoos commented Aug 13, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Which package are you modifying?

Primitives

  • accordion
  • alert
  • alert-dialog
  • aspect-ratio
  • avatar
  • badge
  • breadcrumb
  • button
  • calendar
  • card
  • carousel
  • checkbox
  • collapsible
  • combobox
  • command
  • context-menu
  • data-table
  • date-picker
  • dialog
  • dropdown-menu
  • form-field
  • hover-card
  • icon
  • input
  • input-otp
  • label
  • menubar
  • navigation-menu
  • pagination
  • popover
  • progress
  • radio-group
  • scroll-area
  • select
  • separator
  • sheet
  • skeleton
  • slider
  • sonner
  • spinner
  • switch
  • table
  • tabs
  • textarea
  • toggle
  • toggle-group
  • tooltip
  • typography

Others

  • trpc
  • nx
  • repo
  • cli

What is the current behavior?

Closes #606

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

I removed the changed output from the date-picker and date-multi picker. The model two way binding is changed to a normal input and linked signal. For ngModel and forms the date model is emitting to many events.

Other information

@MerlinMoos MerlinMoos marked this pull request as draft August 13, 2025 15:06
@MerlinMoos MerlinMoos marked this pull request as ready for review August 14, 2025 14:37
Copy link
Collaborator

@ashley-hunter ashley-hunter left a comment

Choose a reason for hiding this comment

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

Thanks very much! Great work! I took an initial look over the code - didn't get much time, but I spotted a few small things, but functional seems to work well.

I know we chatted quite a bit about API and functionality, so it would perhaps be good to get few others sets of eyes on this in case they have other thoughts or suggestions that maybe we did not think of 😊

Thanks again, really nice addition!

@MerlinMoos
Copy link
Contributor Author

MerlinMoos commented Aug 15, 2025

Hey @ashley-hunter you are not wrong at all, but when you use it like this

protected readonly _mutableDisabled = linkedSignal(this.disabled);

it is working, because the linkedSignal is having the reference to the signal itself and not to the value of the signal

this is wrong you also get a compiler issue
protected readonly _mutableDisabled = linkedSignal(this.disabled());

this is working
protected readonly _mutableDisabled = linkedSignal(this.disabled);

this is also working
protected readonly _mutableDisabled = linkedSignal(() => this.disabled());

you need to pass a computation and not a value :)

image

Copy link
Collaborator

@marcjulian marcjulian left a comment

Choose a reason for hiding this comment

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

Awesome addition with the calendar and date picker range! Left a couple of comments

Comment on lines +137 to +163
selectDate(date: T): void {
const start = this.startDate();
const end = this.endDate();

if (!start && !end) {
this.startDate.set(date);

return;
}

if (start && !end) {
if (this._dateAdapter.isAfter(date, start)) {
this.endDate.set(date);
} else if (this._dateAdapter.isBefore(date, start)) {
this.startDate.set(date);
this.endDate.set(start);
} else if (this._dateAdapter.isSameDay(date, start)) {
this.endDate.set(date);
}
return;
}

// If both start and end are selected, reset selection
this.startDate.set(date);

this.endDate.set(undefined);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if dateDisabled input is passed and some dates are disabled. Should we allow range selection over a disabled date?

For example the 6th is disabled and I select the 4th and than the 8th.

Should the range be 4.8 - 8.8 or should the start date reset to 8th because the 6th is disabled? If we want this type of selection, should it maybe be a config option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh this is a great catch, hmm... at least angular material is just allowing to set min and max date. Maybe we should not allow to disable single dates in a date range picker? I don't find a use case for that maybe you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

A use case for a date range picker could be to select a date range for some kind of booking like accommodation. Then it would make sense to allow disabling single or multiple dates and thus the range should not allow selection with disabled dates in between.

I guess that use case and feature is very specific. Not sure if we need it in the first implementation or add it later when needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is very special, then we just should not allow it and implement multiple date ranges. This we can implement later in my point of view

Comment on lines +94 to +96
public readonly date = input<T>();

protected readonly _mutableDate = linkedSignal(this.date);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am just curious, why not use model but instead use an input and linkedSignal? Isn't model exactly that but just as one value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sadly not... for e.g. the date is touched in the writeValue. In that case the model is emiting a change event which is actually not true. This is the reason why i splitted that up.

Copy link
Collaborator

@ashley-hunter ashley-hunter left a comment

Choose a reason for hiding this comment

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

Thanks very much for the updates! Looking great! I think there is a conflict that needs resolved, and just one issue I spotted is if I change month and select a range, when the popover closes and open again it reverts back to the current month, whereas I believe we should restore it to the month with the selection.

@MerlinMoos
Copy link
Contributor Author

hey @ashley-hunter I restore now the calendar to the startday

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.

Add date range picker
3 participants