Created
June 2, 2016 19:45
-
-
Save mnpenner/4a52366150deaa44d377c872c7d1fda3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkOffset = $.datepicker._checkOffset; | |
$.extend($.datepicker, { | |
_checkOffset: function(inst, offset, isFixed) { | |
if(!isFixed) { | |
return checkOffset.apply(this, arguments); | |
} | |
let isRTL = this._get(inst, "isRTL"); | |
let obj = inst.input[0]; | |
// copied from Datepicker._findPos (node_modules/jquery-ui/datepicker.js) | |
while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) { | |
obj = obj[isRTL ? "previousSibling" : "nextSibling"]; | |
} | |
let rect = obj.getBoundingClientRect(); | |
return { | |
top: rect.top, | |
left: rect.left, | |
}; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I’ve looked Into this to find the root of the problem, since I wanted to keep the original repositioning of the datepicker intact. The snippets shown here remove horizontal repositioning. The issue seems to be
checkOffset
trying compare two differently calculated offsets. In my case that caused positioning to bork out on bordered inputs within a fixed container after scrolling the page.It turned out to be a 1 line fix in jQuery UI. Here is the pull request: jquery/jquery-ui#1935
Hopefully it’ll also fix your usecase. If it does drop a line in the pull request to confirm, it’ll help get it merged.