selectize.js icon indicating copy to clipboard operation
selectize.js copied to clipboard

Close method calls deprecated `$.fn.blur()`

Open mikevaux opened this issue 3 years ago • 4 comments
trafficstars

I did:

  • [x] Search for if my issue has already been submitted
  • [x] Make sure I'm reporting something precise that needs to be fixed
  • [x] Give my issue a descriptive and concise title
  • [ ] Create a minimal working example on JsFiddle or Codepen (or gave a link to a demo on the Selectize docs)
  • [x] Indicate precise steps to reproduce in numbers and the result, like below

The close method calls the deprecated $.fn.blur() shorthand:

if (self.isBlurring) {
    self.$control_input.blur(); // close keyboard on iOS
}

This triggers a warning when running jQuery Migrate.

Steps to reproduce:

  1. Click selectize element to open the items dropdown.
  2. Click an item to select it.
  3. Click out of the selectize control

Expected result: No deprecation warning

Actual result: Deprecation warning

Further Details:

I think #1625 referenced this, but the PR which closed that issue (#1624) only actually addressed $.fn.trim(), not $.fn.blur().

I wonder if this could be as simple as updating as follows, but I'm not confident in it:

if (self.isBlurring) {
-    self.$control_input.blur(); // close keyboard on iOS
+    self.$control_input[0].blur(); // close keyboard on iOS
}

Happy to create a PR if it is thought that this is the way to go! :-)

mikevaux avatar Mar 17 '22 10:03 mikevaux

Or

if (self.isBlurring) {
-    self.$control_input.blur(); // close keyboard on iOS
+    self.$control_input.trigger('blur'); // close keyboard on iOS
}

if that is preferable...

mikevaux avatar Mar 17 '22 10:03 mikevaux

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Jul 16 '22 02:07 github-actions[bot]

Maybe this issue is not pressing ? long thermal jquery will be completely removed..

fabienwnklr avatar Sep 16 '22 20:09 fabienwnklr

I agree that it's not pressing, though I think probably work a fix when someone gets time, especially as it's presumably a simple fix (see my suggestions above). If the jQuery team release e.g. a version 4.0 which drops support altogether, this could well break the whole script.

I also agree that jQuery is becoming less of a requirement for a lot of projects, but I think it's very unlikely that this whole library will be rewritten without jQuery as a dependency any time soon, so I think unless there is a clear roadmap for that, we shouldn't assume that jQuery will be dropped here.

Happy to be disagreed with! :)

mikevaux avatar Sep 20 '22 08:09 mikevaux