Skip to content

onOutsideRange constantly and needlessly recomputes thousands of time #245

Closed
@timhwang21

Description

@timhwang21

It looks like onOutsideRange() is recomputed for EVERY SINGLE DATE every single time the datepicker is interacted with, be it clicking, or even hovering over dates.

My test function:

isOutsideRange(day) {
  console.log(counter++); // counter is a global variable

  return false;
}

The result:

When opening the datepicker for the first time (clicking an input), Chrome debugger logs up to 2519:

screen shot 2017-01-11 at 1 42 29 pm

When the mouse enters or leaves any calendar date, Chrome debugger logs an additional 560 (18 months worth of days?) calls. Finally, subsequent closing / opening of the datepicker logs an additional 160 calls (560 * 3, significant?)

If the isOutsideRange() function is anything more than trivial, this results in a very noticeable performance slowdown.

Ideally, the result of isOutsideRange() should be cached for each day, or should only be calculated for localized days, e.g. for all the dates currently visible ± 7 days (to account for outside days).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions