Opened 4 years ago

Last modified 3 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 4 years ago by scottgonzalez

  • Keywords haspatch added
  • Milestone changed from 1.10.0 to 1.11.0
  • Status changed from new to open
  • Version changed from git to 1.9.0

comment:2 Changed 3 years ago by scottgonzalez

  • Milestone changed from 1.11.0 to none

comment:3 Changed 3 years ago by scottgonzalez

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