Opened 9 years ago

Closed 3 years ago

#6127 closed bug (duplicate)

Datepicker: When using yearRange cannot initially use previous or next arrows

Reported by: diackne@… Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.8.5
Keywords: dropdown-month-year with yearRange go to out of year range Cc:
Blocked by: Blocking:

Description

dropdown-month-year with yearRange

<script>
	$(function() {
		$( "#datepicker" ).datepicker({
			changeMonth: true,
			changeYear: true,
                        yearRange: '1900:2010'

		});
	});
	</script>

when select last year 1900 and last month jan, the button preview becomes active, if press in button prev, the year in selectbox is max of range 1900 and month changes, but when you select one day, the year is out of range.

Change History (9)

comment:1 Changed 7 years ago by Scott González

Milestone: TBD1.11.0

comment:2 Changed 7 years ago by mikesherov

Status: newopen

Confirmed: http://jsfiddle.net/FWWZ7/

Steps to reproduce:

  1. Click the previous month arrow button until Jan 1900 is displayed.
  2. Hit previous month arrow button

expected: rolls over to Dec. 2010

actual: rolls over to December 1900

If you then choose any month using the month select dropdown, the behavior above produces the expected result.

comment:3 in reply to:  2 Changed 6 years ago by patrickkostjens

Replying to mikesherov:

Confirmed: http://jsfiddle.net/FWWZ7/

Steps to reproduce:

  1. Click the previous month arrow button until Jan 1900 is displayed.
  2. Hit previous month arrow button

expected: rolls over to Dec. 2010

actual: rolls over to December 1900

If you then choose any month using the month select dropdown, the behavior above produces the expected result.

In the jsfiddle (with jQuery UI 1.8.18), it seems to roll over to December 1900 indeed (it is what the dropdowns display). When you get the datepicker's data however, the selectedYear property is 1899, not 1900.

Edit: In the master checkout, the button is disabled. Should this issue be considered resolved?

Last edited 6 years ago by patrickkostjens (previous) (diff)

comment:4 Changed 6 years ago by tj.vantoll

Milestone: 1.11.0none
Summary: dropdown-month-year with yearRange go to out of year rangeDatepicker: When using yearRange cannot initially use previous or next arrows

Well https://github.com/jquery/jquery-ui/commit/eca5abd873675f5cc7b96641c723b7e35a4260bc (which landed in 1.10.0) does seem to have mostly resolved this. However there still is a small problem - now when the calendar is initially loaded the previous and next arrows are disabled when they shouldn't be. See http://jsfiddle.net/tj_vantoll/n24ws/.

I'll update this ticket to be more specific to that issue.

comment:5 Changed 6 years ago by robotdan

The API documentation indicates the yearRange should not restrict which dates may be selected.

yearRange

Note that this option only affects what appears in the drop-down, to restrict which dates may be
    selected use the minDate and/or maxDate options.

Currently _isInRange is using the year range to restrict selection it seems.

I have some proposed changes to fix the issue demonstrated here http://jsfiddle.net/tj_vantoll/n24ws/. But I wonder if the logic being used in _isInRange should be re-evaluated first?

The API seems to indicate that yearRange should really be used along with minDate and maxDate if the widget is to enforce the Year range displayed in selector. Or maybe I'm not understanding something correctly.

comment:6 in reply to:  5 Changed 6 years ago by tj.vantoll

Replying to robotdan:

The API documentation indicates the yearRange should not restrict which dates may be selected.

yearRange

Note that this option only affects what appears in the drop-down, to restrict which dates may be
    selected use the minDate and/or maxDate options.

Currently _isInRange is using the year range to restrict selection it seems.

I have some proposed changes to fix the issue demonstrated here http://jsfiddle.net/tj_vantoll/n24ws/. But I wonder if the logic being used in _isInRange should be re-evaluated first?

The API seems to indicate that yearRange should really be used along with minDate and maxDate if the widget is to enforce the Year range displayed in selector. Or maybe I'm not understanding something correctly.

That jsFiddle URL is the same one from my earlier comment. I'm guessing you meant to give a different one.

In general, we're not making any changes to datepicker's API as a rewrite is in progress: http://wiki.jqueryui.com/w/page/12137778/Datepicker. If we can fix this bug then that's fine, but the APIs need to remain as-is.

Also we'd love to have some help with the rewrite :)

comment:7 Changed 6 years ago by robotdan

I have some proposed changes to fix the issue demonstrated here http://jsfiddle.net/tj_vantoll/n24ws/. But I wonder if the logic being used in _isInRange should be re-evaluated first?

That jsFiddle URL is the same one from my earlier comment. I'm guessing you meant to give a different one.

Oh, sorry, my wording wasn't very clear. I only meant, I had some local changes that I have not yet submitted a pull request for that fix the issue you demonstrated in this jsFiddle http://jsfiddle.net/tj_vantoll/n24ws/.

Maybe I'll just submit a pull request when I get a moment, and see where it goes from there.

I would be interested in helping with some of the rewrite.

comment:8 in reply to:  7 Changed 6 years ago by tj.vantoll

Replying to robotdan:

I have some proposed changes to fix the issue demonstrated here http://jsfiddle.net/tj_vantoll/n24ws/. But I wonder if the logic being used in _isInRange should be re-evaluated first?

That jsFiddle URL is the same one from my earlier comment. I'm guessing you meant to give a different one.

Oh, sorry, my wording wasn't very clear. I only meant, I had some local changes that I have not yet submitted a pull request for that fix the issue you demonstrated in this jsFiddle http://jsfiddle.net/tj_vantoll/n24ws/.

Maybe I'll just submit a pull request when I get a moment, and see where it goes from there.

I would be interested in helping with some of the rewrite.

Sounds good. If you're interesting in helping out with the rewrite checkout the wiki page (http://wiki.jqueryui.com/w/page/12137778/Datepicker) and the branch (https://github.com/jquery/jquery-ui/tree/datepicker). At the moment I'm specifically looking for help implementing a min and max option.

Ping us on IRC (http://irc.jquery.org/) and we can help you get started - although we're all in San Diego at a team meeting right now so we might not be able to get back with you until next week.

comment:9 Changed 3 years ago by Scott González

Resolution: duplicate
Status: openclosed

Duplicate of #8873.

Note: See TracTickets for help on using tickets.