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

Add keepMounted option and fix screen glitch #516

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pikaju
Copy link

@pikaju pikaju commented Feb 14, 2023

Adds option that keeps the Modal mounted even when it is hidden. This is useful for keeping the DOM state inside the Modal as well as for SEO purposes.

Fixes #233 and #495

@pradel
Copy link
Owner

pradel commented Mar 9, 2023

Thanks for the pr! Could you please add an example in the docs so I can try it?

.react-responsive-modal-overlay,
.react-responsive-modal-container,
.react-responsive-modal-modal {
animation-fill-mode: forwards !important;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please explain why this is needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes a separate issue #495. I copied the solution from one of the people in that thread. To be honest, I'm not sure why it helps, but it does.

@codecov
Copy link

codecov bot commented Mar 9, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.16 🎉

Comparison is base (16aad65) 95.28% compared to head (d2c9bb4) 95.45%.

❗ Current head d2c9bb4 differs from pull request most recent head 11fd42a. Consider uploading reports for the commit 11fd42a to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #516      +/-   ##
==========================================
+ Coverage   95.28%   95.45%   +0.16%     
==========================================
  Files           6        6              
  Lines         191      198       +7     
  Branches       69       74       +5     
==========================================
+ Hits          182      189       +7     
  Misses          9        9              
Impacted Files Coverage Δ
react-responsive-modal/src/index.tsx 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pikaju
Copy link
Author

pikaju commented Mar 16, 2023

Hey @pradel, thanks for the response. I added an example and docs in the Next project.

I also changed how modals are centered, from the "inline" behavior to flex-box centering. I did this because there was an issue when the modal had little space (e.g. on a mobile device) and the pseudo-element you had before was wrapped to a new line. This implementation doesn't do that.

@pikaju pikaju requested a review from pradel March 16, 2023 18:06
@@ -103,6 +104,26 @@ You can also set to trap focus within the modal, but decide where to put focus w

```

### Keeping a hidden modal mounted

By setting the `keepMounted` property to `true`, you can specify that the modal should always be mounted to the DOM, even when hidden it is hidden.
Copy link

@akoll akoll Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a small typo:

Suggested change
By setting the `keepMounted` property to `true`, you can specify that the modal should always be mounted to the DOM, even when hidden it is hidden.
By setting the `keepMounted` property to `true`, you can specify that the modal should always be mounted to the DOM, even when it is hidden.

@pradel
Copy link
Owner

pradel commented Apr 22, 2023

@pikaju could you please split the pr into two parts?

  • the keepMounted can be released as a minor version first
  • then the change you made to the CSS for the mobile issue, this one will need to be released as a breaking change as it may conflict with the CSS used by users of this package

@pikaju
Copy link
Author

pikaju commented May 4, 2023

@pradel Sorry, but that doesn't seem worth the effort, I suggest just releasing a new major version

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 this pull request may close these issues.

Save state DOM tree
4 participants