Opened 10 years ago

Last modified 9 years ago

#8737 open bug

Datepicker: hidden input without sibling should use parent for position

Reported by: sorpigal Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.9.0
Keywords: rewrite position Cc:
Blocked by: Blocking:

Description

If you have a datepicker bound to a hidden input (being invoked manually, in my case via click handler on an unrelated element) and the datepicker has no visible elements following it within its container, then _findPos will throw a null reference exception.

The problem is that _findPos looks at nextSibling until it finds a non-hidden one, but if this never happens obj will be null after the while loop. My solution was to walk up to the parent if no visible siblings could be found, which looks like this:

	_findPos: function(obj) {
		var inst = this._getInst(obj);
		var isRTL = this._get(inst, 'isRTL');
		while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
			obj = obj[isRTL ? 'previousSibling' : 'nextSibling'] || obj.parentNode;
		}
		var position = $(obj).offset();
		return [position.left, position.top];
	},

The changed line being:

			obj = obj[isRTL ? 'previousSibling' : 'nextSibling'] || obj.parentNode;

Change History (3)

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

Keywords: haspatch added
Milestone: 1.10.01.11.0
Status: newopen
Version: git1.9.0

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

Milestone: 1.11.0none

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

Keywords: rewrite position added; haspatch removed
Note: See TracTickets for help on using tickets.