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

Router use_navigate duplicates # sign of fragment in URL #3647

Open
LioQing opened this issue Feb 23, 2025 · 0 comments
Open

Router use_navigate duplicates # sign of fragment in URL #3647

LioQing opened this issue Feb 23, 2025 · 0 comments

Comments

@LioQing
Copy link

LioQing commented Feb 23, 2025

Describe the bug
When using use_navigate or any reactive element that uses it (e.g. query_signal), the # of the fragment in the URL gets duplicated, e.g. 127.0.0.1:8080/#fragment to 127.0.0.1:8080/?key=1##fragment

Leptos Dependencies

leptos = { version = "0.7.7", features = ["csr"] }
leptos_router = "0.7.7"

To Reproduce

use leptos::prelude::*;
use leptos_router::hooks::query_signal;
use leptos_router::components::Router;

#[component]
fn View() -> impl IntoView {
    let (_, set_query) = query_signal::<i32>("key");

    view! {
        <a href="#fragment">
            <h1>fragment</h1>
        </a>
        <button on:click=move |_| set_query.set(Some(1))>
            <h1>set one</h1>
        </button>
    }
}

#[component]
fn App() -> impl IntoView {
    view! {
        <Router>
            <View/>
        </Router>
    }
}

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

The issue also occur if simply try to navigate("#fragment", Default::default()) but since router currently does not support fragment so it is expected that might happen, but for URL that already has a fragment created from a HTML element, I think it should at least preserve the fragment part.

Expected behavior
It should preserve the original fragment part, e.g. in the code to reproduce the URL should go from 127.0.0.1:8080/#fragment to 127.0.0.1:8080/?key=1#fragment.

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

No branches or pull requests

1 participant