F
F
Forname2020-05-21 20:33:29
React
Forname, 2020-05-21 20:33:29

Why does the modal close on any click?

https://jsfiddle.net/7jze1skt/

We need it to close only when the overlay is clicked. I put a click on it, but the modal closes even if you click on it, and it's impossible to enter anything. Help me fix it please.

And one more thing - why does the form open only with a double click, and not with the first one, when it already appeared and closed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dmitry-toster, 2020-05-22
@dmitry-toster

fixed

Why does the modal close on any click?

Because it is necessary to check event.target- the element on which the click actually occurred
Why does the form only open on double click?

The logic was wrong, the function of opening / closing the modal window should be one and it must be forwarded through props

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question