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

datepicker: add yearRangeReverse property sort year in reverse order #6521

Open
wants to merge 2 commits into
base: v1-dev
Choose a base branch
from

Conversation

k2s
Copy link

@k2s k2s commented Feb 23, 2020

This add yearRangeReverse property to date picker to sort year range in reverse order

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist:

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

js/datepicker.js Outdated
}
}
arr = arr.concat(opts.yearRangeReverse ? years.reverse() : years);
Copy link
Contributor

@DanielRuf DanielRuf May 29, 2020

Choose a reason for hiding this comment

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

Not sure why arr.concat is used here. You can probably leave the old code untouched and use one line with this:

if(opts.yearRangeReverse) {
  arr.reverse();
}

Which will reverse the array elements in place.

Copy link
Contributor

Choose a reason for hiding this comment

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

You might also want to add it as default at the top.

Copy link
Author

Choose a reason for hiding this comment

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

@DanielRuf I fixed the overhead.
Pls. what do you mean by add it as default at the top ?

Copy link
Contributor

Choose a reason for hiding this comment

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

See https://github.com/Dogfalo/materialize/blob/v1-dev/js/datepicker.js#L4, the defaults are readable and visible when you output a component instance on the console.

@DanielRuf
Copy link
Contributor

Merged at materializecss@5a4c33c (includes the original commits at https://github.com/materializecss/materialize/commits/v1-dev).

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.

2 participants