Material-ui-pickers: Hide ok button when autoOk is true or create a new property to hide ok button

Created on 22 Dec 2017  ยท  9Comments  ยท  Source: mui-org/material-ui-pickers

Hello, I'm just starting with ui-pickers components and I got a minor UX problem.

Environment

any

Steps to reproduce

  1. Use DatePicker with autoOk set to true

Expected behavior

Cancel button align to the right and no ok button on screen when autoOk is set to true OR a new property like showOkButton

Actual behavior

Ok button appears on screen, if I pass okLabel as empty it is gone but the cancel button still far from the right side border because the ok button is there, only without a visible label

Live example

Not need, it is very simple to check

Thanks!

enhancement

Most helpful comment

Action buttons are part of the material-ui DialogActions component. You can hide this section using CSS overrides within your material-ui theme. For example:

createMuiTheme({
  overrides: {
    MuiPickersModal: {
      dialogAction: {
        display: "none"
      }
    }
  }
})

All 9 comments

Hmm, its just really weird feature request. What if user needs only change the date without time, he would like to approve changes - and there is no submit button.

I am actually cannot understand this feature โ“

Anyway I`m not aware of the new prop, so if you need to - I will approve the PR, but please describe the flow :)

In case of DateTimePicker I think Ok button is necessary (like @dmtrKovalenko described).

But we can leave decision for developers, providing the way to hide buttons.

I would suggest to hide button completely if empty string label is provided.
So if provided okLabel='' - ok button will be not rendered at all.

Ok, I'll work on that in my release sprint.

Thanks for your reply ;)

Even now, when okLabel is set for empty string, button is getting rendered,
Isn't there any way to hide ok and cancel buttons?

Action buttons are part of the material-ui DialogActions component. You can hide this section using CSS overrides within your material-ui theme. For example:

createMuiTheme({
  overrides: {
    MuiPickersModal: {
      dialogAction: {
        display: "none"
      }
    }
  }
})

Hi,
Is there a way to style for example : the [OK] button independently from the [cancel],
because as you already know "dialogAction" will be applied on all elements in the section.

Updated snippet, to disable "Cancel" and "OK". In case if someone needs it.

const THEME = createMuiTheme({
  overrides: {
    MuiDialogActions: {
      root: {
        display: 'none',
      },
    },
    MuiPickersSlideTransition: {
      transitionContainer: {
        marginBottom: 12,
      },
    },
  },
})

Can I override only the date picker?
When I do this all of my dialog lost the action buttons.

Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brett-patterson picture brett-patterson  ยท  3Comments

StevenRasmussen picture StevenRasmussen  ยท  3Comments

aditya81070 picture aditya81070  ยท  3Comments

danmce picture danmce  ยท  3Comments

mnemanja picture mnemanja  ยท  3Comments