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

Elements with Transition not in DOM until show is true #44

Closed
jorgeramos opened this issue Oct 5, 2020 · 8 comments · Fixed by #106
Closed

Elements with Transition not in DOM until show is true #44

jorgeramos opened this issue Oct 5, 2020 · 8 comments · Fixed by #106

Comments

@jorgeramos
Copy link

I'm working on an app that is using Transition for opening the modal menu used for navigation. The menu opens and closes as desired, however, the markup is not visible on the DOM unless it is open. This is problematic for SEO as that content would not be visible to the search engine crawlers. How can I make the component behave visually just as it is now, but just toggle the visibility so that the markup is always there?

You can see the behavior in the example app: https://b6xje.csb.app/

Screen Shot 2020-10-05 at 9 55 02 AM

Screen Shot 2020-10-05 at 9 55 18 AM

@sebastianmulders
Copy link

The same is true for when <Transition /> contains input definitions of a form. For example, when applying a transition on a set of conditional fields and that condition is false, the hidden fields are not part of the form request when submitting. That makes sense because they are not present in the dom.

I have not found a solution for this other than in my case defining a couple of hidden inputs outside of the transition. You could also consider defining the same content elsewhere and hide it manually. Perhaps not the most beautiful solution, but it'll do for now.

@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

Both scenarios are true because we unmount the whole tree. I am going to experiment with an idea to make it stay in the DOM.

I'll keep you posted!

@Tzelon
Copy link

Tzelon commented Oct 7, 2020

+1
It will be very useful if we have a prop that toggles that behavior.

@jorgeramos
Copy link
Author

@RobinMalfait can you share what you have in mind? This is pretty critical so I'd like to give it a shot if you don't have the bandwidth at the moment.

@jorgeramos
Copy link
Author

Hey! Thank you for your bug report!
Much appreciated! 🙏

Both scenarios are true because we unmount the whole tree. I am going to experiment with an idea to make it stay in the DOM.

I'll keep you posted!

Hi, do you think you'll have time over the next couple of days for this one? I'd love to jump in and work on it. Can you point me in the right direction with the ideas you had?

@RobinMalfait
Copy link
Member

@jorgeramos Hey! I'm working on this the next couple of days. I will get back to this very shortly!

@RobinMalfait
Copy link
Member

Hey! Small update: This should be working in the next version we publish.

Usage:

Put an unmount={false} on all the the Transition or Transition.Child elements that you want to keep in the DOM. From a visual perspective this should behave exactly the same. From a DOM perspective the components that have unmount={false} will get a hidden prop and a style={{ display: 'none' }}

The default value of unmount is true, so make sure to put it everywhere where you need it.

<Transition unmount={false} />
<Transition.Child unmount={false} />

@jorgeramos
Copy link
Author

@RobinMalfait thanks for working on this. Do you have an expected date for the next release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants