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

Components are rendering out of order when mixed with HTML elements #53

Closed
jquesada2016 opened this issue Nov 6, 2022 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@jquesada2016
Copy link
Contributor

Using version 0.0.15, the following results in out of order rending:

use leptos::*;
use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn start() {
  mount_to_body(view_fn);
}

fn view_fn(cx: Scope) -> impl Mountable {
  view! { cx,
    <form>
      <TextInput />
      <button>"Clcik me?"</button>
    </form>
  }
}

#[component]
fn TextInput(cx: Scope) -> Element {
  view! {cx,
    <input />
  }
}

If I inline the component, i.e, <form><input /> ..., then it works, if I remove the surrounding <form> then it also renders correctly.

@gbj
Copy link
Collaborator

gbj commented Nov 6, 2022

Thanks, I'll take a look.

For you or anyone else who wants an ugly quick fix in the interim, wrapping the component in a

should almost certainly put them in the right order.

@jquesada2016
Copy link
Contributor Author

Can confirm wrapping components in (what I presume to be <span> does work, at least with all the different experiments I've tried.

I'm working on a relatively large project and will report on any other odd behaviors I may find. I'll also try to read up on the source so I can make pull requests so you're not doing everything by yourself.

If you believe you can get a chance on perhaps making a quick doc somewhere describing how the internals work, that would go a huge way for me and other contributers to be able to help. I can also open an issue on this topic, or document everything I find while going through the source.

@gbj gbj added the bug Something isn't working label Nov 7, 2022
gbj added a commit that referenced this issue Nov 7, 2022
Fix the out-of-order component/element rendering in #53.
@gbj gbj closed this as completed Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants