mui / material-ui-pickers

Date & Time pickers for Material UI (support from v1 to v4)
https://github.com/mui/material-ui-pickers/issues/2157
MIT License
2.32k stars 833 forks source link

[DateRangePicker] renderDay not being called #1856

Closed bneigher closed 4 years ago

bneigher commented 4 years ago

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?
oliviertassinari commented 4 years ago

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

bneigher commented 4 years ago

@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?

oliviertassinari commented 4 years ago

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!

bneigher commented 4 years ago

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