Skip to main content

Search and Top Navigation

#6127 closed bug (duplicate)

Opened September 30, 2010 11:09AM UTC

Closed October 23, 2016 12:02PM UTC

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

Reported by: diackne@gmail.com 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.

Attachments (0)
Change History (9)

Changed October 11, 2012 09:04PM UTC by scottgonzalez comment:1

milestone: TBD1.11.0

Changed October 18, 2012 05:37PM UTC by mikesherov comment:2

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.

Changed November 12, 2013 07:09PM UTC by patrickkostjens comment:3

_comment0: Replying to [comment:2 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. 1384285125401302

Replying to [comment:2 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?

Changed November 13, 2013 02:40AM UTC by tj.vantoll comment:4

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.

Changed February 08, 2014 07:54AM UTC by robotdan comment:5

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.

Changed February 10, 2014 01:54PM UTC by tj.vantoll comment:6

Replying to [comment:5 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 :)

Changed February 12, 2014 06:34AM UTC by robotdan comment:7

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.

Changed February 12, 2014 01:07PM UTC by tj.vantoll comment:8

Replying to [comment:7 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.

Changed October 23, 2016 12:02PM UTC by scottgonzalez comment:9

resolution: → duplicate
status: openclosed

Duplicate of #8873.