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

crop area becomes smaller #409

Closed
Cikayo opened this issue Sep 15, 2022 · 6 comments
Closed

crop area becomes smaller #409

Cikayo opened this issue Sep 15, 2022 · 6 comments

Comments

@Cikayo
Copy link

Cikayo commented Sep 15, 2022

It is normal for the first operation.
image

However, there is a problem with the second operation.
image

I need your help.Thanks!

@ValentinH
Copy link
Owner

What is different between the two cases? Could you please share a codesandbox showing the issue?

@Cikayo
Copy link
Author

Cikayo commented Sep 15, 2022

What is different between the two cases? Could you please share a codesandbox showing the issue?

Here is my code.
https://codesandbox.io/s/suspicious-ishizaka-fquxnh?file=/src/App.js

After selecting an image for the first time, click Cancel. Problem selecting another image the second time.

@ValentinH
Copy link
Owner

I'm not fully getting why this is happening but it seems to be related with the way antd-modal hides its content when the modal is closed.

I managed to fix it by not rendering the modal at all if imageUrl is empty:
image

and reset it on cancel:
image

Here's a working sandbox:
https://codesandbox.io/s/blissful-zeh-tur30j?file=/src/App.js

@Cikayo
Copy link
Author

Cikayo commented Sep 15, 2022

Wow! It's working. Thanks!

At first, I thought it was the component Cropper that cached the image. And try the code. I'm going in the wrong direction.

image

Thank you again for your help.

@ValentinH
Copy link
Owner

Yes this is also the first thing I tried as there are often issues when the Cropper is rendered outside of screen. For example, when a modal is closed but its content isn't unmounted.

@ValentinH
Copy link
Owner

If you don't want to fully unmount the modal when it's just supposed to be closed, you can have a look to #267. You might have some luck there as the author was using the Modal from antd (dont know how similar it is to antd-mobile Mask).

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

2 participants