-
Notifications
You must be signed in to change notification settings - Fork 254
Dialog state does not change on close #221
Comments
I'm very new to React so forgive my ignorance, here is what I've done to solve it. Hope this helps some one. The following did not work (The event might be unsupported by React?)
So I did the following:
Now when a user presses escape, or exits the dialog without using the button, the state is correctly set and the dialog can be opened once more. Edit: Code works as a drop-in to the examples. |
Thanks for reporting the issue! Using the I'm thinking of cancelling the escape key by default, unless the user provide a |
Hi @tleunen, thanks for the link. there are some new things regarding the native dialog element that I have learned.
I couldn't find the doc that says
Yeah, I agree. |
I initially thought it was an attribute I'll open a ticket in React to know if they plan to add the |
So I have a fix (quite easy to do), but I also wanted to add some tests to make sure we don't introduce regressions later, but I have some hard time finding how to check that the dialog closes or not when the user pressed the escape key :/ If you have some time @Permagate, could you take a look to see if there's a way? |
I didn't test the code now, but going by what @t1bb4r has said, if I would have expected to see instead of
But perhaps I'm missing something. |
Indeed, But there's a difference between what you define as props in your own components, and what's defined on the React elements. For the |
I agree that components should have as little state as possible and like the fact that you made the default for But given the following code:
Would react actually handle the |
Nop, if you specify the |
@tleunen Heya, I was preoccupied with other things last week, so I just take a look at the fix today. I agree with @skaapgif. I think specifying onCancel props still doesn't replace the I have to change the following:
to
to prevent the |
You don't have to manually listen the event yourself, the component does it for you. |
Ah, I'm talking about the component itself: https://github.com/tleunen/react-mdl/blob/master/src/Dialog/Dialog.js#L19 |
Oh damn you're right. It should be |
Haha, glad to see I wasn't going crazy 👍 |
I think the Dialog component should set its state to
{openDialog: false}
on 'dialogclose'.Currently if a user presses the escape key to close the dialog it wont open again since the openDialog state is still set to true.
This can be reproduced using the demo page:
Unexpected state can easily be inspected using the react developer tools.
Edit: I'm using Chrome Version 48.0.2564.82 (64-bit)
The text was updated successfully, but these errors were encountered: