Skip to main content

Search and Top Navigation

#8737 open bug ()

Opened October 26, 2012 02:34PM UTC

Last modified July 14, 2014 06:40PM UTC

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;
Attachments (0)
Change History (3)

Changed October 26, 2012 02:48PM UTC by scottgonzalez comment:1

keywords: → haspatch
milestone: 1.10.01.11.0
status: newopen
version: git1.9.0

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

milestone: 1.11.0none

Changed July 14, 2014 06:40PM UTC by scottgonzalez comment:3

keywords: haspatchrewrite position