Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialog box in Material UI opens with a weird gray background

Im using Material UI with React and have a dialog which comes up when a button is tapped. The button is present in a table which in turn is presented over a Paper component. The issue is when I use the dialog with default styling, the background turns black. I tried making the styling as transparent but now Im getting a gray artifact behind dialog. The original dialog with default styling:

Dialog with default styling

The dialog with transparent attributes:

    <Dialog
      title="ALERT - Confirm Action? "
      modal={false}
      overlayStyle={{backgroundColor: 'transparent'}}
      bodyStyle={{margin:0, padding:0}}
      actions={
        <div>
          <FlatButton
              label="Cancel"
              primary={true}
              onClick={this.handleCloseTwo}
          />
          <FlatButton
              label="Submit"
              type="submit"
              primary={true}
              keyboardFocused={true}
              onClick={() => {
                this.setState({ dialogTwo: false });
              }}
          />
        </div>
      }
      open={this.state.dialogTwo}
  >
  </Dialog>

This is how it renders: enter image description here

like image 784
SeaWarrior404 Avatar asked Sep 10 '25 10:09

SeaWarrior404


2 Answers

I have the solution now. Your dialog code (

<Dialog> </Dialog>

), put them outside the component you use.

example:

<Table>
....
<IconButton> Dialog Show </IconButton>
<Dialog> .............. </Dialog>
....
</Table>

put them like this

<Table>
....
<IconButton> Dialog Show </IconButton>
....
</Table>

<Dialog> .............. </Dialog>
like image 93
darkscripter Avatar answered Sep 13 '25 00:09

darkscripter


If anybody still stumble upon this, and do not notice the the answer from Mikhail Shabrikov in the comments, because its not posted as an answer:

It looks like many dialogs opened at the same time. – Mikhail Shabrikov Oct 26 '17 at 9:07

I have been back to this page at least the 3. time in the last year, thus adding this answer because I keep missing this (and keep putting my dialogs in iterators) :).

like image 28
Don Kartacs Avatar answered Sep 13 '25 01:09

Don Kartacs