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

DatePicker: Selecting "Year" then "Month" on iOS causes component to throw error #4178

Closed
flatlevel opened this issue Jun 15, 2020 · 3 comments · Fixed by #4245
Closed

DatePicker: Selecting "Year" then "Month" on iOS causes component to throw error #4178

flatlevel opened this issue Jun 15, 2020 · 3 comments · Fixed by #4245

Comments

@flatlevel
Copy link

Environment

  • Package version(s): verified on both 3.22.2 and 3.28.2
  • Operating System: iOS 13.5
  • Browser name and version: Safari Mobile 13.1

Code Sandbox

Can be reproduced on Blueprint's site: https://blueprintjs.com/docs/#datetime/datepicker

bug

Steps to reproduce

  1. Add blueprint's date picker
  2. Open date picker on iOS safari mobile
  3. Select year "iOS scroll wheel" but do not choose a year
  4. Select month
  5. White screen, JS error

Actual behavior

Screen turns white, error

TypeError: undefined is not an object (evaluating 'd.length')

Expected behavior

I will see the month iOS scroll wheel and choose the appropriate month.

Possible solution

I believe this issue is related: #3603

@adidahiya
Copy link
Contributor

Blueprint is not tested for mobile usage, it is designed for desktop applications, so this is low priority for the project. Open to bugfix PRs, though.

@jez321
Copy link
Contributor

jez321 commented Jul 24, 2020

I've had a look into this and found a couple of things

  • It seems that safari on iOS fires onChange events for select boxes when they are focused and blurred, even if the value doesn't change
    -> Codesandbox here: https://codesandbox.io/s/hidden-hooks-y5k00?file=/src/App.js
    Visit in iOS safari and tap each select box alternately, notice the console messages.
    You'll also notice the value of the select box on screen changes when you focus it. On blur it returns to the correct value if you don't select a new one so it's not a huge deal and I don't think we can do much about it anyway but wait for a fix to safari/iOS.

  • This itself shouldn't result in a crash but the value for e.target safari passes with these change events in some cases (the case above) is an empty string, which results in an Invalid date and crash.

  • I'm not sure why we get an empty string sometimes as this doesn't happen in the codesandbox, perhaps someone with more knowledge of DatePicker can shed some light on it (maybe due to some of the custom focus/blur handling?)

  • A simple way to stop the crashes at least would be to just ignore the change event if the value passed is an invalid date or empty string. If this seems acceptable I can make a PR for it.

@adidahiya
Copy link
Contributor

A simple way to stop the crashes at least would be to just ignore the change event if the value passed is an invalid date or empty string. If this seems acceptable I can make a PR for it.

Sure, I would accept a PR for this. Make sure to include a code comment about how this change is iOS-specific

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

Successfully merging a pull request may close this issue.

3 participants