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

When month selector is open, change date by year instead of month #114

Closed
Edward-Ta opened this issue Apr 26, 2021 · 6 comments
Closed

When month selector is open, change date by year instead of month #114

Edward-Ta opened this issue Apr 26, 2021 · 6 comments

Comments

@Edward-Ta
Copy link

Edward-Ta commented Apr 26, 2021

Hi, when you open the month selector I would like the arrows to change from 'changing months' to 'changing years'.
I have implemented this locally in an awkward sort of way by checking if its open or not, I'm wondering if its possible to get this developed properly?

Locally I just added this:

if(document.getElementsByClassName("month-selector open").length != 0){
		direction = direction * 12;
	}

to the incremementMonth function in svelte-calendar/src/Components/DatePicker.svelte

  function incrementMonth(direction, day = 1) {
    if (direction === 1 && !canIncrementMonth) return;
    if (direction === -1 && !canDecrementMonth) return;
    let current = new Date(year, month, 1);
	if(document.getElementsByClassName("month-selector open").length != 0){
		direction = direction * 12;
	}
    current.setMonth(current.getMonth() + direction);
    month = current.getMonth();
    year = current.getFullYear();
    highlighted = new Date(year, month, day);
  }

Thank you.

@coccus1991
Copy link

Hi, when you open the month selector I would like the arrows to change from 'changing months' to 'changing years'.
I have implemented this locally in an awkward sort of way by checking if its open or not, I'm wondering if its possible to get this developed properly?

Locally I just added this:

if(document.getElementsByClassName("month-selector open").length != 0){
		direction = direction * 12;
	}

to the incremementMonth function in svelte-calendar/src/Components/DatePicker.svelte

  function incrementMonth(direction, day = 1) {
    if (direction === 1 && !canIncrementMonth) return;
    if (direction === -1 && !canDecrementMonth) return;
    let current = new Date(year, month, 1);
	if(document.getElementsByClassName("month-selector open").length != 0){
		direction = direction * 12;
	}
    current.setMonth(current.getMonth() + direction);
    month = current.getMonth();
    year = current.getFullYear();
    highlighted = new Date(year, month, day);
  }

Thank you.

Thx for suggestion i've implemented your snippet code on my project locally. Very helpful!

@6eDesign
Copy link
Owner

6eDesign commented Aug 7, 2021

The calendar supports arrows and page up/down keys currently. In the next version the arrows will control the current context (day, year, month, or time picker) and the page up/down arrows will control the "next" level of picker (ex: on day picker they move months [like today], on month picker they control years, etc).

I may be able to allow some customization of the keys but I think what I have coded in the new version currently is a more intuitive default implementation for keyboard users than what is requested here.

@Edward-Ta
Copy link
Author

Edward-Ta commented Aug 9, 2021

Okay, a question I have then is, who is a keyboard user...
i.e.:
What front end user is likely to be using their keyboard to navigate a datepicker over their mouse?
While its great for a power user to quickly navigate the datepicker with those keys, a lot of the people I know that will be using my system have never used arrow keys in their life.

Thank you for replying.

@jonathangreenemeier-vizio

The arrow UI elements are still present in the new version and work the same as page up/down keys when clicked.

@6eDesign
Copy link
Owner

svelte-calendar@3.x was recently released and has an updated UX around the day, month, and year pickers along with many other enhancements and some breaking-changes to the component's API (hopefully all for the better). Feel free to check it out and provide feedback here or in a new issue.

@Edward-Ta
Copy link
Author

Looks great will start using now!

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

No branches or pull requests

4 participants