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

🐞 - DateRange + minLength / maxLength (with month / year params) has incorrect limits #1884

Open
2 of 9 tasks
nsbarsukov opened this issue Dec 4, 2024 · 0 comments
Open
2 of 9 tasks
Labels
bug Something isn't working scope: kit Related to @maskito/kit

Comments

@nsbarsukov
Copy link
Member

nsbarsukov commented Dec 4, 2024

Which package(s) are the source of the bug?

@maskito/kit

Playground Link

https://maskito.dev/kit/date-range/API?maxLength$=1

Description

Reproduction

Case 1

  1. Open https://maskito.dev/kit/date-range/API?maxLength$=1 (maxLength: {month: 1})
  2. Enter 01.01.2025 – 01.02.2025

Expected behavior: 31.01.2025 is max allowed end of date range
Actual behavior: mask allows to enter 01.02.2025

Case 2

  1. Open https://maskito.dev/kit/date-range/API?maxLength$=1 (maxLength: {month: 1})
  2. Enter 31.01.2025 – 03.03.2025

Expected behavior: 27.02.2025 is max allowed end of date range
Actual behavior: mask allows to enter 03.03.2025


Why the current behavior is incorrect ?

Explore Taiga UI's CalendarRange behavior:
https://taiga-ui.dev/components/calendar-range/API?maxLength$=1 (maxLength: {month: 1})

calendar-range.mov

How to solve this issue ?

Modify the following logic

export function appendDate(
initialDate: Date,
{day, month, year}: Partial<MaskitoDateSegments<number>> = {},
): Date {
const date = new Date(initialDate);
if (day) {
date.setDate(date.getDate() + day);
}
if (month) {
date.setMonth(date.getMonth() + month);
}
if (year) {
date.setFullYear(date.getFullYear() + year);
}
return date;

to satisfy Taiga UI behavior.

Maskito version

3.2.0

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android
@nsbarsukov nsbarsukov added bug Something isn't working scope: kit Related to @maskito/kit labels Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working scope: kit Related to @maskito/kit
Projects
None yet
Development

No branches or pull requests

1 participant