Opened 8 years ago

Last modified 3 years ago

#7580 open feature

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.

Change History (5)

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

Status: newopen

comment:2 Changed 6 years ago by Scott González

Milestone: 1.9.01.11.0

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

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/

comment:4 Changed 5 years ago by Scott González

Milestone: 1.11.0none

comment:5 Changed 3 years ago by syryos2

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);
 	},
 
Note: See TracTickets for help on using tickets.