Material-ui-pickers: [DateRangePicker] renderDay not being called

Created on 4 Jun 2020  路  4Comments  路  Source: mui-org/material-ui-pickers

Environment

| Tech | Version |
| -------------------- | ------- |
| @material-ui/pickers | v4.0.0-alpha7 |
| material-ui | v4.10.0 |
| TypeScript | No |
| React | 16.13.1 |
| Browser | Chrome |
| Peer library | moment |

Steps to reproduce

  1. Create Wrapping Component:
import React, { useState } from 'react'
import classNames from 'classnames'
import { StaticDateRangePicker as DateRangePicker, Day } from '@material-ui/pickers'
import { makeStyles } from '@material-ui/core/styles'
import TextField from '@material-ui/core/TextField'
import moment from 'moment'

const useStyles = makeStyles((theme) => ({}))

const StaticDateRangePicker = (props) => {
    const classes = useStyles()

    return (
        <DateRangePicker
            autoOk
            orientation="portrait"
            variant="static"
            openTo="date"
            disableOpenPicker
            value={props.range}
            onChange={(newRange) => {
                props.onChangedDate(newRange[0], newRange[1] ? newRange[1] : newRange[0])
            }}
            showTodayButton
            disableFuture
            views={['date']}
            renderInput={(startProps, endProps) => (
                <>
                    <TextField {...startProps} />
                    <TextField {...endProps} />
                </>
            )}
            renderDay={(day, selectedDates, DayComponentProps) => console.log("I'm a sailor")}
        />
    )
}

export { StaticDateRangePicker }

Calling Component

render() {
 <StaticDateRangePicker
     range={[moment().subtract(1, "day"), moment()]}
     onChangedDate={(dateA, dateB) => {
    this.onSetDateRange(dateA, dateB)
     }} />
}

Expected behavior

Expect my dream career title to be logged to the console

Actual behavior

Appears the custom renderDay prop is being ignored, or some condition is overruling the default renderDay method

Anyone else seeing this?

bug 馃悰 DateRangePicker

All 4 comments

You import StaticDateRangePicker, it contains the content of the popup, it's isolated from the inputs.

@oliviertassinari I'm sorry, I don't believe you answered the question...

There is a render method (renderDay) which allows us to make custom day components. It is called correctly on the static day picker, it is not being called on the static day range picker where the documentation says it is a prop.

I'm not referring to the renderInput method. Can you reopen or at least address this please?

Please provide a minimal reproduction test case. This would help a lot 馃懛 .
A live example would be perfect. This codesandbox.io template _may_ be a good starting point. Thank you!

@oliviertassinari
Note the renderDay method not being called
https://codesandbox.io/s/reverent-faraday-fs49n?file=/src/App.jsx

Was this page helpful?
0 / 5 - 0 ratings

Related issues

basselAhmed picture basselAhmed  路  3Comments

brett-patterson picture brett-patterson  路  3Comments

idrm picture idrm  路  3Comments

nicky-dev picture nicky-dev  路  3Comments

callmeberzerker picture callmeberzerker  路  3Comments