arqex / react-datetime

A lightweight but complete datetime picker react component.
1.99k stars 873 forks source link

Unhandled error being thrown in Safari/MacOS #784

Open brian-kane521 opened 3 years ago

brian-kane521 commented 3 years ago

I'm Submitting a ...

[x] Bug report
[ ] Feature request
[ ] Support request

Steps to Reproduce

The issue is only appearing for certain users, specifically in Safari. Simply navigating to a page with a DateTime component causes an unhandled error to be thrown.

Expected Results

This appears to be an issue that should be caught internally - nothing appears to be abnormal in our code base looking through the stack trace.

Actual Results

An unhandled error is thrown: TypeError: undefined is not an object (evaluating 'this.getRow(n,a++).push') it appears the variables n as well as a are both undefined. The code is minified, so I don't know have much further than that. Is there perhaps some missing type checking/validation?

Other Information (e.g. stacktraces, related issues, suggestions how to fix)

The react-datetime code causing the issue is the following:

{
      key: "renderDays",
      value: function value(e, t, n) {
        var r = [[], [], [], [], [], []],
            o = e.clone().subtract(1, "months");
        o.date(o.daysInMonth()).startOf("week");

        for (var a = o.clone().add(42, "d"), i = 0; o.isBefore(a);) {
          // THE FOLLOWING LINE THROWS:
          this.getRow(r, i++).push(this.renderDay(o, t, n)), o.add(1, "d");
        }

        return r.map(function (e, t) {
          return c.a.createElement("tr", {
            key: "".concat(a.month(), "_").concat(t)
          }, e);
        });
      }
    },
johnhunter commented 2 years ago

Cannot reproduce this error with Safari 15.0 / MacOS 11.6. I've checked with both the Codesandbox demo and running the local playground. Also not had any reports from Safari users (we use react-datetime our application).

The source of the error is

let row = getRow( rows, i++ );
row.push( this.renderDay( startDate, startOfMonth, endOfMonth ) );

https://github.com/arqex/react-datetime/blob/master/src/views/DaysView.js#L71-L72

When minified the row is inlined so the TypeError is probably due to an undefined row. I'm not sure why that should fail unless there is an issue with momentjs date logic.

@brian-kane521 Can confirm if this is still an issue? If so perhaps you could provide a bit more information, e.g. Safari version, what props are provided to the Datetime component and which version of react-datetime you are using.