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

preventDefault for the un-zoom button #746

Open
kayvaninvemo opened this issue Oct 17, 2024 · 9 comments · Fixed by #763
Open

preventDefault for the un-zoom button #746

kayvaninvemo opened this issue Oct 17, 2024 · 9 comments · Fixed by #763
Assignees

Comments

@kayvaninvemo
Copy link

onClick={handleUnzoom}

here we need to preventDefault, otherwise it causes un expected behaviour if the zoom component it self is inside a dialog.

@rpearce
Copy link
Owner

rpearce commented Oct 21, 2024

@kayvaninvemo do you have time to put an example into a CodeSandbox that I can test with?

@rpearce
Copy link
Owner

rpearce commented Nov 3, 2024

@kayvaninvemo I unfortunately don't yet understand what the problem is. If you can help me understand it with a demo, that would be helpful.

@tjx666
Copy link

tjx666 commented Nov 3, 2024

@rpearce

try here: https://stackblitz.com/edit/vitejs-vite-nddcft?file=src%2FApp.tsx

  1. click button to open dialog
  2. click image in dialog to open zoomed image
  3. click the zoomed image
    • expect: only exit the zommed state, but keep dialog open
    • actual: not only exit the zoomed state, but also exit modal

@kayvaninvemo
Copy link
Author

@tjx666 this is exactly my issue. I did a workaround here

      onClose={(e: any) => {
        if (e.target?.id?.match(/rmiz-modal-.*/)) {
          return;
        }
        handleClose();
      }}

@rpearce
Copy link
Owner

rpearce commented Nov 7, 2024

@tjx666 @kayvaninvemo Got it! Will fix. Many thanks for y'all's patience and sharing info.

@rpearce
Copy link
Owner

rpearce commented Nov 12, 2024

Well, I thought this would be fixed in react-medium-image-zoom@5.2.11, but I went back to that stackblitz, updated the package.json, re-installed, and gave it a whirl, but no difference.

Could one of y'all give this a try for me? It's not impossible @mui/material is doing something unexpected.

@rpearce rpearce reopened this Nov 12, 2024
@djaffer
Copy link

djaffer commented Nov 28, 2024

If zoom is used for an image inside the dialog. When unzoomed it closes the dialog too.

@rpearce
Copy link
Owner

rpearce commented Dec 4, 2024

@djaffer This was not the case for me when I tested with a plain dialog element. Are you also using @mui/material?

@djaffer
Copy link

djaffer commented Dec 4, 2024

Yes. I fixed by using @kayvaninvemo answer. Thanks to him.

@rpearce rpearce self-assigned this Dec 9, 2024
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

Successfully merging a pull request may close this issue.

4 participants