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

onChange event is not fired on Safari browser #288

Closed
podlesny opened this issue Aug 6, 2020 · 9 comments
Closed

onChange event is not fired on Safari browser #288

podlesny opened this issue Aug 6, 2020 · 9 comments
Assignees
Labels
bug Something isn't working stale

Comments

@podlesny
Copy link

podlesny commented Aug 6, 2020

When I click on datepicker and choose a date, onChange event is not fired in Safari, however in Chrome everything works as expected. I don't have any errors in console. Implementation is similar to this

<DatePicker
 disabled={props.disabled}
showLeadingZeros
format="MM/dd/yy"
calendarIcon={null}
clearIcon={null}
onChange={value=>console.log(value)}
value={props.options.end.val}
/>
@darekkay
Copy link

I cannot reproduce it, it's working fine for me (macOS 10.15.5, Safari 13.1.1.).

@pedrofsantoscom
Copy link

pedrofsantoscom commented Aug 31, 2020

@podlesny are you using the DatePicker inside a modal/dialog, perhaps from MaterialUI? i'm having the same issue with the DatePicker inside the MaterialUI Dialog
you can try this demo: https://codesandbox.io/s/react-date-picker-forked-1ee7e?file=/index.js

@wojtekmaj can you check this one?

@pedrofsantoscom
Copy link

@podlesny Fixed the safari bug using #274 (comment) code and then making this change to the condition:

...
_this.onOutsideAction = event => {
      if (
        _this.wrapper &&
        !_this.wrapper.contains(event.target) &&
        !event.target.className.indexOf('react-calendar') // fix for safari calendar bug
      ) {
        _this.closeCalendar()
        event.stopPropagation()
      }
    }

@moeen-basra
Copy link

moeen-basra commented Sep 24, 2020

@pedrofsantoscom some time event.target.className is object in that case its throwing exception

TypeError: _event$target$classNa.indexOf is not a function

HTMLDocument._this.onOutsideAction

  22 | 
  23 | _this.onOutsideAction = event => {
  24 | 
> 25 |   if (
  26 |     _this.wrapper &&
  27 |     !_this.wrapper.contains(event.target) &&
  28 |     !event?.target?.className?.indexOf('react-calendar') // fix for safari calendar bug

Here is how I fixed this

_this.onOutsideAction = event => {

      if (
        _this.wrapper &&
        !_this.wrapper.contains(event.target) &&
        (typeof  event?.target?.className === 'string' && !event?.target?.className?.indexOf('react-calendar'))
      ) {
        _this.closeCalendar()
        event.stopPropagation()
      }
    }
  })

@jayhaluska
Copy link

jayhaluska commented Feb 28, 2021

Had the same bug both in mobile Safari (iOS 14.4) and desktop Safari (14.0.1). @pedrofsantoscom fix worked perfectly fine, thank you!

For me the calendar worked, when I opened it with the calendar icon. It did not work when I opened it through clicking on the date numbers.

This really needs an official fix.

@wojtekmaj wojtekmaj added the bug Something isn't working label Mar 1, 2021
@wojtekmaj wojtekmaj self-assigned this Mar 1, 2021
@wojtekmaj
Copy link
Owner

I tested on Safari 14.0.1 and onChange works fine:

Nagranie.z.ekranu.2021-03-3.o.08.59.07.mov

and calendar opens on input click just fine as well:

Nagranie.z.ekranu.2021-03-3.o.08.59.55.mov

so I don't know how to reproduce this issue.

@jayhaluska
Copy link

For me the bug was not the opening of the popup, this is working fine. The bug was that it was not possible to choose a value properly. When clicking on a day, the popup closes but the onChange event is not triggered, thus it was not possible to retrieve the date.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2021

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

@github-actions github-actions bot added the stale label Nov 8, 2021
@github-actions
Copy link
Contributor

This issue was closed because it has been stalled for 14 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

6 participants