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

Style display error when the style component specifies the ID #2070

Closed
luoxiaozero opened this issue Nov 24, 2023 · 2 comments
Closed

Style display error when the style component specifies the ID #2070

luoxiaozero opened this issue Nov 24, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@luoxiaozero
Copy link
Contributor

Describe the bug

When the style component specified the ID, there was a problem with the style display after the page was jumped.

Leptos Dependencies

For example:

leptos = { version = "0.5.2", features = ["csr"] }
leptos_meta = { version = "0.5.2", features = ["csr"] }
leptos_router = { version = "0.5.2", features = ["csr"] }
use leptos::*;
use leptos_meta::*;
use leptos_router::*;

#[component]
pub fn App() -> impl IntoView {
    provide_meta_context();
    view! {
        <Router>
            <Routes>
                <Route path="/" view=Home/>
                <Route path="/apple" view=Apple/>
            </Routes>
        </Router>
    }
}

#[component]
pub fn Home() -> impl IntoView {
    let navigate = use_navigate();

    let on_click = move |_| {
        navigate("/apple", Default::default());
    };
    view! {
        <button on:click=on_click>
            <Style id="red">
                "button { color: red }"
            </Style>
            "goto apple page"
        </button>
    }
}

#[component]
fn Apple() -> impl IntoView {
    let navigate = use_navigate();

    let on_click = move |_| {
        navigate("/", Default::default());
    };
    view! {
        <button on:click=on_click>
            <Style id="red">
                "button { color: red }"
            </Style>
            "goto home page"
        </button>
    }
}

fn main() {
    leptos::mount_to_body(App)
}

To Reproduce
Steps to reproduce the behavior:

Click the button repeatedly to jump to the page, and the font color is once red and once black.

Expected behavior
A clear and concise description of what you expected to happen.

The font is always red.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

drop(std::mem::replace(

root.as_ref().map(|route| {
      let (outlet, disposer) = outlet((*route).clone());
      drop(std::mem::replace(
              &mut *root_disposer.borrow_mut(),
               Some(disposer),
      ));
      outlet
})

You should take the last disposer and drop it before executing the outlet function.

@luoxiaozero
Copy link
Contributor Author

let (outlet, disposer) = build_outlet(child);

There are also problems.

@gbj
Copy link
Collaborator

gbj commented Nov 24, 2023

Thank you for the bug report, and especially for identifying the issue! That is very helpful. I believe PR #2071 addresses both of your points, but please let me know if it does not fix the issue for you.

@gbj gbj added the bug Something isn't working label Nov 24, 2023
@gbj gbj closed this as completed in d531848 Nov 24, 2023
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