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

outside click on dialog modal does not dismiss it. #4541

Closed
jasan-s opened this issue Jun 22, 2016 · 9 comments
Closed

outside click on dialog modal does not dismiss it. #4541

jasan-s opened this issue Jun 22, 2016 · 9 comments
Labels
component: modal This is the name of the generic UI component, not the React module!

Comments

@jasan-s
Copy link

jasan-s commented Jun 22, 2016

Problem description

I can click ESC or click the OK(Flat button) and the modal dialog is dismissed however clicking on outside does not trigger onRequestClose. I have set the modal to false according to the docs. What I'm i doing wrong.

Steps to reproduce

  const { handleSubmit, pristine, reset, submitting } = props
  const actions = [
    <FlatButton
        label='Ok'
        primary={true}
        keyboardFocused={true}
        onClick={props.closeModal}/>
  ]
  return (
    <div>
        <RaisedButton label='Duck' onClick= {props.openModal} />

        <div>

            <form onSubmit= {handleSubmit}>
                 <Field name ='duck' component = {(duck) =>
        <Dialog
          title="Dialog With Actions"
          actions={actions}
          modal={false}
          open={props.isOpen}
          onRequestClose={props.closeModal} >
          Only actions can close this dialog.
        </Dialog>}/>
            </form>
        </div>
    </div>
  )

Versions

  • Material-UI: latest release
  • React: latest release
  • Browser: chrome latest release
@stephenkingsley
Copy link

I fix it, now pr

stephenkingsley pushed a commit to stephenkingsley/material-ui that referenced this issue Jun 24, 2016
@mbrookes
Copy link
Member

react-tap-event-plugin?

http://www.material-ui.com/#/get-started/installation

@stephenkingsley
Copy link

@jasan-s you must be use react-tap-event-plugin

@nehalbhanushali
Copy link

@jasan-s is it working now?

@jasan-s
Copy link
Author

jasan-s commented Jun 30, 2016

@stephenkingsley i'm using lated npm module for this lib. and it doesn't use es6 classes. I ll try to figure out how i can make those changes in that module. @mbrookes I tried using onTouchTap and it works fine for non-touch devices but on touch devices the tap registers twice, so the modal open and closes right away. that is why i stuck to just onCLick

@longmfe
Copy link

longmfe commented Jul 4, 2016

I did use react-tap-event-plugin, my issue is that I can dismiss the dialog when I set modal to false, but I can NOT dismiss it when set modal to true. It seems like to act as the opposite way according to the doc.

@mbrookes
Copy link
Member

mbrookes commented Jul 4, 2016

I can dismiss the dialog when I set modal to false, but I can NOT dismiss it when set modal to true. It seems like to act as the opposite way according to the doc.

http://www.material-ui.com/#/components/dialog
"A modal dialog can only be closed by selecting one of the actions."

We could argue the toss about whether that's the correct use of the term "modal", but the behaviour you describe matches the documentation.

@mpontikes mpontikes mentioned this issue Aug 5, 2016
13 tasks
@aahan96
Copy link
Contributor

aahan96 commented Aug 16, 2016

I think we can close this issue then

@aahan96 aahan96 closed this as completed Aug 16, 2016
@oliviertassinari oliviertassinari added the component: modal This is the name of the generic UI component, not the React module! label Apr 5, 2020
@shadyshanab
Copy link

i made a custom solution for this if anyone interested it worked for me without installing any addtional packages
i created a custom fixed div inside the modal with full width and height and give it lower zindex than all the other elements in the modal

<CustomDialog
                onClose={handleClose}
                aria-labelledby={title}
                open={open}
                width={isSmallOrMediumScreen ? "93%" : width}
                TransitionComponent={Transition}
                onClick={onClick}
                ref={ref}
                keepMounted={keepMounted}
                height={height && isSmallOrMediumScreen ? height : 'auto'}
            >
                <div
                    className="fixed top-0 left-0 w-full h-full  z-[1]"
                    onClick={handleClose}
                />
                <DialogTitle id={title} className="z-[2]">
                    <CloseButton aria-label="close" onClick={handleClose}>
                        <FaArrowLeft
                            style={{fontSize: '20px'}}
                        />
                    </CloseButton>
                    <span style={{color: '#F8775D', fontWeight: '700', paddingRight: '10px'}}>{title}</span>
                </DialogTitle>
                <DialogContent dividers className="z-[2]">{children}</DialogContent>
                {firstButton && secondButton && (
                    <DialogActions
                        className="z-[2]"
                    sx={{
                        display: 'flex',
                        gap: '10px',
                        margin: '10px',
                        }}
                    >
                        <Button autoFocus className="z-[2]" onClick={firstButtonAction} color="primary">
                            {firstButton}
                        </Button>
                        <Button autoFocus className="z-[2]" onClick={secondButtonAction} color="primary">
                            {secondButton}
                        </Button>
                    </DialogActions>
                )}
            </CustomDialog>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: modal This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

8 participants