Skip to content

Scrolling behavior of href="#anchor", hx-get="url#anchor" and hx-target"#anchor" #968

@BoPeng

Description

@BoPeng

Where do we expect the page to scroll to when we have anchor specified in href and hx-get? For example

<a href="#" hx-get="url" hx-target="#target" hx-swap="outerHTML scroll:top"></a>

should scroll to #target.

Where does

<a href="#anchor" hx-get="url" hx-target="#target" hx-swap="outerHTML scroll:top"></a>

scroll to? #anchor or #target?

And how about the following

<a href="#" hx-get="url#anchor" hx-target="#target" hx-swap="outerHTML scroll:top"></a>

or

<a href="#anchor" hx-get="url#anchor1" hx-target="#target" hx-swap="outerHTML scroll:top"></a>

Logically speaking, I think the page should scroll to #anchor in the last three cases but I am not sure if this is how htmx implements hx-swap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions