Skip to main content

Search and Top Navigation

#7580 open feature ()

Opened July 26, 2011 10:54AM UTC

Last modified November 23, 2015 08:22PM UTC

Datepicker: Ability to position current month out of view with showCurrentAtPos option

Reported by: copesc Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.8.14
Keywords: Cc:
Blocked by: Blocking:
Description

Hi, I've made a small jsfiddle to clarify the issue:

http://jsfiddle.net/Hsy5w/

If you go forward to january 2012, the first 2 months are undefined, when showCurrentAtPos is set as -2.

If I set showCurrentAtPos: -1, the first month is undefined.

Attachments (0)
Change History (5)

Changed July 26, 2011 12:17PM UTC by scottgonzalez comment:1

status: newopen

Changed October 11, 2012 02:43PM UTC by scottgonzalez comment:2

milestone: 1.9.01.11.0

Changed April 03, 2013 06:09PM UTC by scottgonzalez comment:3

summary: Using showCurrentAtPos gives an undefined month when changing yearDatepicker: Ability to position current month out of view with showCurrentAtPos option
type: bugfeature

Changing to a feature request. I'm pretty sure showCurrentAtPost was never meant to be used with the current month out of view.

Updated test case: http://jsfiddle.net/Hsy5w/1/

Changed June 24, 2014 11:46PM UTC by scottgonzalez comment:4

milestone: 1.11.0none

Changed November 23, 2015 08:22PM UTC by syryos2 comment:5

I found a solution and patched the jquery-ui.js in basically two code lines in the datepicker subroutines _adjustDate() and _updateDatepicker() (see also cross-posting in http://bugs.jqueryui.com/ticket/9923#comment:4 ):

--- jquery-ui.orig.js	2015-11-23 20:04:52.000000000 +0100
+++ jquery-ui.js	2015-11-23 17:56:37.987111191 +0100
@@ -8815,6 +8815,8 @@
 				origyearshtml = inst.yearshtml = null;
 			}, 0);
 		}
+		// FIX BUG http://bugs.jqueryui.com/ticket/7288
+		inst.drawMonth += this._get(inst, "showCurrentAtPos");
 	},
 
 	// #6694 - don't focus the input if it's already focused
@@ -8940,9 +8942,14 @@
 		if (this._isDisabledDatepicker(target[0])) {
 			return;
 		}
+		// FIX BUG http://bugs.jqueryui.com/ticket/7288
+		/*
 		this._adjustInstDate(inst, offset +
 			(period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
 			period);
+		*/
+		this._adjustInstDate(inst, offset, period);
+
 		this._updateDatepicker(inst);
 	},