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

How to get around Dialog non-cancellable events #1120

Open
kale1d0code opened this issue Oct 24, 2023 · 2 comments
Open

How to get around Dialog non-cancellable events #1120

kale1d0code opened this issue Oct 24, 2023 · 2 comments

Comments

@kale1d0code
Copy link

kale1d0code commented Oct 24, 2023

I've been using this library every time I need to create a user-interface and I must say its so awesome having all these components implementations ready to go.

However I noticed that certain elements don't behave exactly how you'd expect them to.

For example the Dialog component ignores the open property if it is closed for some reason which can also break it, making it not open again.
The event for closing the dialog isn't cancellable either.

I went around this by setting open and preventOutsideDismiss to always be true, and then wrap the whole thing in CSSTransition using the CSSTransition "in" prop to animate the dialog in or out only when open changes.

This could also be done without CSS Transition like so

const Example = ({open, ...props}) => (
  <>
    {
        open ? (
          <Dialog
            open={true}
            {...props} />
        ) : null
    }
  </>
)

The scrim can also be reimplemented by adding a div element before or just after the Dialog component with absolute positioning to cover the whole screen and giving it a onClick handler for setting open (you may also needs to play with z-index however don't set it higher than 6 otherwise your scrim will be in front of your dialog)

the following css also needs to be added otherwise our custom scrim won't get a onClick event.

.mdc-dialog__container,
.mdc-dialog.mdc-dialog--open {
	pointer-events: none;
}

also don't use the DialogButton components as clicking these closes the Dialog also (MDC implementation).
regular Button components look the same and don't exhibit this behaviour.

@b-d-m-p
Copy link
Member

b-d-m-p commented Oct 26, 2023

Hey! @kale1d0code Thanks for the issue! We are working on the v14 release, but we will take a deep look at this right after!

@EmiBemi
Copy link
Member

EmiBemi commented Apr 4, 2024

Hi, just to verify, are you using strict mode? Right now there is an issue with some components not working in strictmode. This is a much bigger problem that we would love to address, but is a bit difficult. If you are using strictmode, try to disable it. If not, I'll take a look at this bug. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants