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

fix(kit): fix calendar range presets filtration #9777

Merged

Conversation

bondarvladislave
Copy link
Contributor

@bondarvladislave bondarvladislave commented Nov 18, 2024

Summary
I need to add a preset for the calendar: "Previous Period". This preset ensures that the selected period has the same length and directly precedes the current selection.

For example:

  • If the selected range is 14–15, the preset will suggest 12–13.
  • If the selected range is 10–15 (length 6), the preset will suggest 4–9.

Implementation Details
Ensures that the previous period matches the minLength and maxLength of the current selection.
Adjusts the range so the new period is directly adjacent to the current selection, maintaining its exact length.

Issue
https://stackblitz.com/edit/angular-ckrt12?file=src%2Fapp%2Fapp.component.ts,src%2Fapp%2Fapp.template.html
In the example at the link, the dates are different; it will always be Today - 2 days.
The length ends up being 3 days inclusive.
The preset will be:
from: today - (3 + 2) and to: today - 3

The library's filtering logic rejects the preset dates in some cases.

telegram-cloud-photo-size-2-5312075690281136275-x

However, I can select these dates manually, and in that case, the preset label is applied to the input.

telegram-cloud-photo-size-2-5312075690281136276-x

For example:
When the selected range is 14–15, the preset suggests 12–13.
minLength = 2, but 12 + 2 = 14.
The library's mapper treats this as invalid because 14 does not satisfy daySameOrBefore with the "to" date, which is day 15.

telegram-cloud-photo-size-2-5312075690281136277-x

Proposed Fix
In the filtering logic, it seems necessary to include an adjustment like append({ day: -1 }) to correctly validate the preset's range.

@bondarvladislave bondarvladislave requested a review from a team as a code owner November 18, 2024 13:49
@bondarvladislave bondarvladislave requested review from MarsiBarsi, waterplea, nsbarsukov, vladimirpotekhin and mdlufy and removed request for a team November 18, 2024 13:49
Copy link

lumberjack-bot bot commented Nov 18, 2024

Pull request was closed ✔️

All saved screenshots (for current PR) were deleted 🗑️

Copy link

bundlemon bot commented Nov 18, 2024

BundleMon

Unchanged files (5)
Status Path Size Limits
demo/browser/main.(hash).js
304.37KB +10%
demo/browser/vendor.(hash).js
260.09KB +10%
demo/browser/runtime.(hash).js
44.03KB +10%
demo/browser/styles.(hash).css
19.63KB +10%
demo/browser/polyfills.(hash).js
11.18KB +10%

Total files change +2B 0%

Unchanged groups (1)
Status Path Size Limits
demo/browser/*..js
7.34MB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@mdlufy mdlufy force-pushed the calendar-range-preset-validation branch 2 times, most recently from 0bf93cc to 354423c Compare November 19, 2024 15:35
@splincode splincode force-pushed the calendar-range-preset-validation branch from 354423c to 9588ada Compare November 19, 2024 15:37
@splincode splincode merged commit bfeb254 into taiga-family:main Nov 20, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants