Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Custom toolbar is not overriding the header label and arrow icons in date-picker #7763

Closed
2 tasks done
venkateshpullaganti opened this issue Jan 30, 2023 · 2 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information

Comments

@venkateshpullaganti
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

I searched the docs and issues but not able to find a solution. I might be missing something.

import React from 'react';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import enLocale from 'date-fns/locale/en-US';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { FormControl, TextField } from '@material-ui/core';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
import styled from 'styled-components';
import css from './styles.module.scss';

const CustomToolbar = (props) => {
    console.log('TCL: CustomToolbar -> props', props);
    return (
        <div>
            Custom Toolbar:
            <button onClick={() => props.setOpenView('year')}>Year</button>
            <button onClick={() => props.setOpenView('month')}>Month</button>
            <button onClick={() => props.setOpenView('day')}>Day</button>
        </div>
    );
};

export default function index() {
    return (
        <Wrapper className={css.wrapper}>
            <LocalizationProvider
                dateAdapter={AdapterDateFns}
                adapterLocale={enLocale}
            >
                <DatePicker
                    value={new Date()}
                    closeOnSelect
                    views={['year', 'month', 'day']}
                    onChange={console.log}
                    renderInput={(params: any) => (
                        <FormControl fullWidth>
                            <TextField {...params} fullWidth />
                        </FormControl>
                    )}
                    showToolbar
                    ToolbarComponent={CustomToolbar}
                />
            </LocalizationProvider>
        </Wrapper>
    );
}

const Wrapper = styled.div`

`;

Current behavior 😯

Screenshot 2023-01-30 at 6 16 15 PM

Expected behavior 🤔

The Month name, year and the arrow buttons should not be visible.

Context 🔦

I am trying to achieve the
Screenshot 2023-01-30 at 6 16 15 PM

Your environment 🌎

Environment Details:

  • Mac book pro m1
  • Chrome 109
  • Node : 18.8.0
  • Ts : 4.8.4
  • Next js : 12.13.1
  • React 18.2.0

Order ID 💳 (optional)

No response

@venkateshpullaganti venkateshpullaganti added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 30, 2023
@flaviendelangle
Copy link
Member

flaviendelangle commented Jan 30, 2023

The header you are referring to is not the toolbar but the header of the date views (day, month and year).
The toolbar is common to any view whereas this header will not appear on the time views.

We have the issue #6653 which focuses on the override of this part of the UI.
I think it would solve your problem as well.
Once this slot is implemented, you would just have to pass a component returning null to it (or we would support the value null like we do on the grid to say to render nothing.

I'll close this issue after you confirm that I understood your need correctly, so that we keep a single issue 👍

As for the time it will take for this feature to land.
Since it's the 2nd use case for this exact same slot, I think we can create it in the near future 👍

@flaviendelangle flaviendelangle added component: pickers This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 30, 2023
@flaviendelangle flaviendelangle changed the title Custom toolbar is not overriding the header label and arrow icons in date-picker [pickers] Custom toolbar is not overriding the header label and arrow icons in date-picker Jan 30, 2023
@flaviendelangle flaviendelangle added the status: waiting for author Issue with insufficient information label Jan 30, 2023
@github-actions
Copy link

github-actions bot commented Feb 6, 2023

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.

@github-actions github-actions bot closed this as completed Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

2 participants