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

HTML Anchor hash support in link-to template #12997

Closed
bkCDL opened this issue Feb 22, 2016 · 10 comments
Closed

HTML Anchor hash support in link-to template #12997

bkCDL opened this issue Feb 22, 2016 · 10 comments

Comments

@bkCDL
Copy link

bkCDL commented Feb 22, 2016

I'm working on a single-page app where the index route has many sections as a user scrolls down their screen. For this to work, I want to use the HTML anchor hash property. I see in this closed issue from last year that Ember supports default browser behavior of linking to anchor hash properties, for which I'm grateful. It also mentions the possibility of creating a "fragment" feature of the {{link-to}} component. When I try it on my site (Em 2.3.0) and in this twiddle, it doesn't work, and I don't see it in the source code.

Is this a supported feature, whether now or in the future? I notice that when I just put a element in my handlebars template, the user's click of the anchor hash ends up triggering a reload of the page when I'm on another route rather than a mere route transition, which is why I'd like to use {{link-to}} instead of a mere element. How else might I utilize anchor hash properties in Ember?

Thanks,

Bryan

@mmun
Copy link
Member

mmun commented Feb 23, 2016

There is no hash/fragment support in the router or with link-to.

I'm not sure why <a href="#some-id"> isn't working in ember-twiddle. It does work fine in JSbin:

http://emberjs.jsbin.com/gabune

@stefanpenner
Copy link
Member

@mmun does this seem like a twiddle only issue or have i misread?

@mmun
Copy link
Member

mmun commented Feb 26, 2016

Yes, the specific issue reported here seems to be in ember-twiddle. It would be nice to have better hash/fragment support in the router but should be discussed in the RFCs repo.

@cfator
Copy link

cfator commented Mar 4, 2016

I am using locationType="history" and an anchor like this:

admin

reloads the page to "http://localhost:4200/#c4412370-e892-11e4-a199-000c29a61086"

This is with Ember-cli/Ember 2.4.1.

@camunching
Copy link

I don't think this is a Twiddle-only issue. Here is a JSBin where the issue doesn't show up on the index route, but it does show up on any other route.

To reproduce:

  1. Visit http://jsbin.com/bilewi
  2. Click on "bottom" - works fine
  3. Scroll back up and click on "foo" - you are now on the foo page
  4. Click on "bottom" - should take you to the bottom of the foo page, but instead it takes you to the bottom of the index page

I am experiencing the same issue with anchor links in my Ember 2.4.3 app

@alexspeller
Copy link
Contributor

Note: <a href='#foo'> works fine if you are on the index route. It does not work correctly on other routes, instead causing a full page refresh

@jakeleboeuf
Copy link

jakeleboeuf commented Jan 27, 2017

Yea, this would be real nice.

{{link-to "Cool Feature" "features#cool"}}   -->   <a href="/features#cool">Features</a>

@danieledraganti
Copy link

Any new ideas about this? I have tried ember-anchor which is a nice add-on, but requires a little too much configuration, and is not standards-compliant regarding anchors anyway. I believe this should be quite an important feature to implement.

@sdhull
Copy link

sdhull commented May 4, 2018

I opened an issue in the rfcs repo (as suggested). Please 👍 it or add your thoughts emberjs/rfcs#330

@Serabe
Copy link
Member

Serabe commented May 5, 2018

Closing this as is a feature request and @sdhull kindly opened an issue in the RFCs repo.

Thank you all!

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

No branches or pull requests