React-dates: SingleDatePicker Doesnt accept onDayMouseEnter param

Created on 22 Sep 2016  路  9Comments  路  Source: airbnb/react-dates

The SingleDatePicker component doesnt accept onDayMouseEnter param to pass along to the DayPicker component it creates.

onDayMouseEnter(day, modifiers, e) {
    this.setState({
      hoverDate: day,
    });
    this.props.onDayMouseEnter(day, modifiers, e);
}

instead of the current:

onDayMouseEnter(day) {
    this.setState({
      hoverDate: day,
    });
}
wontfix

Most helpful comment

I need to be able to style specific dates differently. I also need to display a tooltip when hovering over those specific dates to display a user a message specific to those dates.

I was able to accomplish this by allowing modifiers to be passed into the SingleDatePicker as well as onDayMouseEnter and onDayMouseLeave callbacks.

I am mostly just curious why the SingleDayPicker and DateRangePicker don't just allow all props of DayPicker to be passed through since both create an instance of DayPicker internally. Is there a reason you chose not to do that?

All 9 comments

What use case would you hope to achieve with such a prop?

I need to be able to style specific dates differently. I also need to display a tooltip when hovering over those specific dates to display a user a message specific to those dates.

I was able to accomplish this by allowing modifiers to be passed into the SingleDatePicker as well as onDayMouseEnter and onDayMouseLeave callbacks.

I am mostly just curious why the SingleDayPicker and DateRangePicker don't just allow all props of DayPicker to be passed through since both create an instance of DayPicker internally. Is there a reason you chose not to do that?

Is there any update on this topic ?

@ljharb Would be the team ready to process a pull request ? (sayin that viewing the PR queue getting bigger and bigger)

There are 15 open PRs; that's nowhere close to being a big queue.

A PR would certainly help continue the discussion.

As for why the DayPicker props aren't all allowed, perhaps @majapw can weigh in.

@majapw What was the reasoning for not exposing those props?

@smoakey the goal of the callbacks as described in https://github.com/airbnb/react-dates/issues/94#issuecomment-249207698 is already supported by using the renderDay prop for custom behavior (like adding a tooltip or having something else happen on mouse interactions). I think exposing the specific day props ends up being messier than just encouraging consumers to use renderDay (especially since it now passes back the list of modifiers applied to that day).

If you want direct access to those callbacks, I kind expect it's because you want a different set-up for selection (like picking weeks at a time or something) and in that case, you probs just wanna use the DayPicker directly and set up your own wrappers.

@majapw Ah thanks for the explanation! It also looks like a lot has changed since I submitted this on v3.0.0 :)

馃檭 definitely! I appreciate you opening the issue though originally! I think it def motivated the creation of that prop.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aaronjensen picture aaronjensen  路  52Comments

mccambridge picture mccambridge  路  20Comments

Jucesr picture Jucesr  路  19Comments

rodryquintero picture rodryquintero  路  70Comments

AntiFish03 picture AntiFish03  路  19Comments