Skip to content

Why no reliable callback of opening the date selector?Β #825

@peshoicov

Description

@peshoicov

I need to fire something each time someone clicks on the input. So I tried with:

onClick={console.log('CLICK')}
onShow={console.log('SHOW')}
onFocus={console.log('FOCUS')}

They all fire when the page loads and never when I click on the input. The date selector with the two months shown, but nothing gets fired.

This is the current implementation:

          <div className={styles.fieldText}>Date Range</div>
          <div className="InputFromTo">
            <DayPickerInput
              ref={...}
              value={from}
              format="MM DD, YYYY"
              placeholder="From"
              formatDate={formatDate}
              parseDate={parseDate}
              onClick={console.log('CLICK')}
              onShow={console.log('SHOW')}
              onFocus={console.log('FOCUS')}
              dayPickerProps={{
                selectedDays: [from, {from, to}],
                disabledDays: {before: todayDate, after: to},
                toMonth: to,
                modifiers,
                numberOfMonths: 2,
                onDayClick: () => {...}
              }}
              onDayChange={this.handleFromChange}/>
            <span className="InputFromTo-to">
              <DayPickerInput
                ref={...}
                value={to}
                format="MM DD, YYYY"
                placeholder="To"
                formatDate={formatDate}
                parseDate={parseDate}
                dayPickerProps={{
                  selectedDays: [from, { from, to }],
                  disabledDays: { before: getDisabledDateTo(todayDate,from) },
                  modifiers,
                  month: from,
                  fromMonth: from,
                  numberOfMonths: 2
                }}
                onDayChange={this.handleToChange}/>
            </span>
        </div>

Am I doing something wrong, or this component really doesn't have such callback :(

PS: Those callbacks fire whenever I choose some date, but I don't want this.
I want a callback of the datepicker opening.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions