-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
Hello,
apologies if this issue does not belong here, I'm not a JavaScript developer
When creating a jQuery UI Datepicker lazily in a delegated focus handler (attach datepicker on focus the first time), the datepicker opens immediately on first focus with jQuery 3.7.1. With jQuery 4.0.0 the datepicker is created but does not open on that initial focus; it only opens after you blur and focus again.
Reproducible test case
- ❌ Not working (jQuery 4.0.0): https://jsfiddle.net/tagliala/vu1jg82p/3
- ✅ Working (jQuery 3.7.1): https://jsfiddle.net/tagliala/vu1jg82p/7/
Minimal repro
HTML
<input placeholder="To" value="" size="12" class="datepicker" maxlength="10" type="text" name="q[created_at_lteq]" id="q_created_at_lteq">JS
(($) => {
$(document)
.on('focus', 'input.datepicker:not(.hasDatepicker)', function() {
const input = $(this);
// Only create datepickers in compatible browsers
if (input[0].type === 'date') { return; }
const defaults = { dateFormat: 'yy-mm-dd' };
const options = input.data('datepicker-options');
input.datepicker($.extend(defaults, options));
});
})(jQuery);Steps to reproduce
- Open the jQuery 4.0.0 fiddle: https://jsfiddle.net/tagliala/vu1jg82p/3
- Click the input (initial focus)
- Click outside (blur)
- Click the input again
Expected
- Datepicker should appear when the input is focused (on step 2) — every time the input is focused after creation.
Actual
- On jQuery 4.0.0 the datepicker does NOT appear on the initial focus (step 2). It only appears after blur and refocus (step 4).
- On jQuery 3.7.1 the datepicker appears on the first focus as expected.
Can the jquery-ui team confirm whether this is:
- an intended behavior change in jQuery 4 that jquery-ui should adapt to, or
- a regression that jquery or jquery-ui should address so create-on-focus patterns still show the datepicker on the very first focus?
Thanks for any help you can provide
Reactions are currently unavailable