Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

datepicker: filter in year mode only validates first of the month #11703

Closed
schliffer opened this issue Apr 8, 2019 · 10 comments · Fixed by #11918
Closed

datepicker: filter in year mode only validates first of the month #11703

schliffer opened this issue Apr 8, 2019 · 10 comments · Fixed by #11918
Assignees
Labels
g3: reported The issue was reported by an internal or external product team. has: Pull Request A PR has been created to address this issue P1: urgent Urgent issues that should be addressed in the next minor or patch release. resolution: fixed severity: regression This issue is related to a regression type: bug type: enhancement
Milestone

Comments

@schliffer
Copy link

Bug, enhancement request, or proposal: Bug

CodePen and steps to reproduce the issue:

CodePen Demo which demonstrates the issue:

https://codepen.io/schliffer/pen/bJBgYP

Detailed Reproduction Steps:

  1. Create a filter on the datepicker that restricts to only weekends
  2. View the datepicker in year mode
  3. Only months that start on a weekend are selectable

What is the expected behavior?

Any month containing a valid date will be selectable in year mode.

What is the current behavior?

Any month where the 1st of the month is valid is selectable in year mode

What is the use-case or motivation for changing an existing behavior?

To allow users to use the year mode in combination with a date filter.

Which versions of AngularJS, Material, OS, and browsers are affected?

  • AngularJS: 1.6
  • AngularJS Material: 1.1.18
  • OS: All
  • Browsers: All

Is there anything else we should know? Stack Traces, Screenshots, etc.

weekends

Fixing this issue: #11525 seems to have caused the problem in year mode.

@jelbourn jelbourn added g3: reported The issue was reported by an internal or external product team. P2: required Issues that must be fixed. labels Apr 8, 2019
@jelbourn
Copy link
Member

jelbourn commented Apr 8, 2019

Related PR: #11526

@dohomi
Copy link

dohomi commented Apr 9, 2019

I have a similar issue with md-datepicker. After version > 1.1.12 randomly dates are invalid without being able to find out whats the reason behind it. I downgraded for now back to 1.1.12 which seems like the last working version for the picker.

@Splaktar Splaktar self-assigned this Apr 9, 2019
@Splaktar Splaktar changed the title Datepicker filter in year mode only validates first of the month datepicker: filter in year mode only validates first of the month Apr 9, 2019
@Splaktar Splaktar added this to the 1.1.19 milestone Apr 9, 2019
@Splaktar
Copy link
Member

Splaktar commented Apr 9, 2019

@dohomi dates are invalid or months/years are invalid?

@Splaktar
Copy link
Member

Splaktar commented Apr 9, 2019

OK, previously in year view, md-date-filter did not work at all (no months would be filtered/disabled).

Are you proposing that we should iterate through every date in every displayed month to determine if any date in a specific month is valid, then if any one date in a month is valid do not filter/disable that month?

Or is the proposal to add an API like md-disable-month-filtering" in order to disable md-date-filter when in year view?

@Splaktar Splaktar added the needs: feedback The issue creator or community need to respond to questions in this issue label Apr 9, 2019
@schliffer
Copy link
Author

I'm fine with any of these 3 ideas (in order of preference):

  1. Add md-enable-month-filtering to opt into the new filtering (will break fewer existing datepickers)
  2. If a datepicker has month mode enabled, iterate through all dates in the month when doing filtering in the year view, otherwise datepicker is broken for this use case.
  3. Reverting the change to add date filtering to the year view

@Splaktar
Copy link
Member

Splaktar commented Apr 9, 2019

None of these options seem ideal to me. However, I just thought of an alternative that may be better.

  1. Add a new md-month-filter API so that developers can provide their own function (that returns a boolean and has a level of performance deemed acceptable to them) to filter months. Revert the change to md-date-filter and update the docs to make it clear that it is only for filtering of days.

Thoughts?

@schliffer
Copy link
Author

I like that idea, preserves both use cases without breaking either.

@Splaktar Splaktar added type: bug type: enhancement severity: regression This issue is related to a regression and removed needs: feedback The issue creator or community need to respond to questions in this issue labels Apr 9, 2019
@dohomi

This comment has been minimized.

@Splaktar

This comment has been minimized.

@Splaktar Splaktar modified the milestones: 1.1.19, 1.1.20 May 30, 2019
@Splaktar Splaktar modified the milestones: 1.1.20, 1.1.21 Aug 15, 2019
@Splaktar Splaktar modified the milestones: 1.1.21, 1.1.22 Sep 30, 2019
@Splaktar Splaktar modified the milestones: 1.1.22, 1.1.23 Oct 22, 2019
@Splaktar Splaktar removed the P2: required Issues that must be fixed. label May 26, 2020
@Splaktar Splaktar added the P1: urgent Urgent issues that should be addressed in the next minor or patch release. label May 26, 2020
Splaktar added a commit that referenced this issue May 26, 2020
…s first day of month

- add `md-month-filter` API
- no longer apply `md-date-filter` to year view
- fix JSDoc typos
- add JSDoc, tests, and demos

Fixes #11703
@Splaktar Splaktar added the has: Pull Request A PR has been created to address this issue label May 26, 2020
@Splaktar
Copy link
Member

Apologies for the delay, but I've posted a PR for this: #11918.

Splaktar added a commit that referenced this issue May 26, 2020
…s first day of month

- add `md-month-filter` API
- no longer apply `md-date-filter` to year view
- fix JSDoc typos
- add JSDoc, tests, and demos

Fixes #11703
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
g3: reported The issue was reported by an internal or external product team. has: Pull Request A PR has been created to address this issue P1: urgent Urgent issues that should be addressed in the next minor or patch release. resolution: fixed severity: regression This issue is related to a regression type: bug type: enhancement
Projects
None yet
4 participants