Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

navigator.userAgent will change in Chrome 101, and currently logs an 'issue' in the console #1781

Closed
3 of 5 tasks
mikevaux opened this issue Apr 7, 2022 · 2 comments · Fixed by #1797
Closed
3 of 5 tasks

Comments

@mikevaux
Copy link

mikevaux commented Apr 7, 2022

I did:

  • Search for if my issue has already been submitted
  • Make sure I'm reporting something precise that needs to be fixed
  • 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)
  • Indicate precise steps to reproduce in numbers and the result

User Agent strings are being reduced in Chrome 101. While it looks like the elements Selectize relies on will still be available, it might be best to migrate to navigator.userAgentData for safety, and also to avoid an issue being raised in the console every time the library is loaded.

navigator.userAgentData is not supported in all browsers, so would need feature detection before ua detection (!) but could be achieved with something along the lines of:

function uaDetect(platform, re) {
  if (navigator.userAgentData) {
    return platform === navigator.userAgentData.platform;
  }

  return re.test(navigator.userAgent);
}

var IS_MAC = uaDetect("macOS", /Mac/);
// Unsure of the `platform` which is reported for Android
var SUPPORTS_VALIDITY_API = !uaDetect("[Android Platform]", /android/i) && !!document.createElement('input').validity;

Would there be any appetite for this? I can look into the platform which is reported for Android devices and create a PR to update both places in the constants.js file if so?

Relatedly, does Selectize still need to support IE < 11? It would be quite nice to move these variables to consts if not, but const is not supported in IE < 11.

@risadams
Copy link
Contributor

risadams commented Apr 7, 2022

That looks like a great change to me. a PR would be appreciated :).

Personally I haven't developed for IE 11 in years, but would need to get community feedback before making that large of a change.

@mikevaux
Copy link
Author

mikevaux commented Apr 7, 2022

That looks like a great change to me. a PR would be appreciated :).

Great! That's fine. I've got a pretty tight project schedule for the next couple of weeks, but I'll do one as soon as I can.

Personally I haven't developed for IE 11 in years, but would need to get community feedback before making that large of a change.

Ha, me neither 😄 Sure, that's fine 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants