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

mainFocus() call in app.js prevents jumping to url anchor on page refresh #1082

Closed
nrser opened this issue Apr 1, 2017 · 7 comments
Closed

Comments

@nrser
Copy link

nrser commented Apr 1, 2017

when you refresh a url like

http://www.rubydoc.info/gems/cmds/Cmds#capture-class_method

the browser doesn't jump to the #capture-class_method anchor.

this appears to be due to the $('#main')[0].focus(); call in mainFocus() at app.js which is fired when the document is ready, jumping focus to the top of the page.

when i comment out the mainFocus() call it works fine in my local environment. what's that call there for? could i add a subsequent call to focus on the anchor from the url if one is present?

it's my guess that this is the cause of #1071 as well.

Steps to reproduce

go to any yard doc page and click on a method link, then hit refresh.

Actual Output

page reloads at top.

Expected Output

page reloads at method anchor.

Environment details:

  • OS: OSX 10.12.3
  • Ruby version (ruby -v): 2.3.3
  • YARD version (yard -v): 0.9.8
  • Relevant software dependency/versions:
    • i'm using Google Chrome Version 56.0.2924.87 (64-bit)
@nrser nrser changed the title mainFocus() call in app.js prevents jumping to url anchor on page load mainFocus() call in app.js prevents jumping to url anchor on page refresh Apr 1, 2017
@nrser
Copy link
Author

nrser commented Apr 1, 2017

update: it turns out this only happens on refresh... which is my common use case as i'm getting used to yard (change some doc source, hit refresh in the browser). so it might be a little more complicated than i first assumed, and could be a browser / environment specific issue (though i would guess Chrome on OSX is pretty common for software developers).

@lsegal
Copy link
Owner

lsegal commented Apr 19, 2017

This was probably used when frames were a thing. I don't think we'd need this anymore. If taking this out looks like it does not cause any other issues I would look at a PR for this.

@lsegal
Copy link
Owner

lsegal commented Apr 23, 2017

Actually, looking at this further, this seems to be necessary-- removing mainFocus() will break keyboard accessibility, i.e., pressing down to scroll the page. This could probably be fixed by changing CSS (I believe the full body has overflow off and the real scroll happens in #main) but that would require more wrangling than simply removing a JS call.

@lsegal lsegal closed this as completed in 3b4ce6d Apr 23, 2017
@lsegal
Copy link
Owner

lsegal commented Apr 23, 2017

Can be solved with JS, too.

lsegal added a commit that referenced this issue Apr 23, 2017
@kmoschcau
Copy link

I'd just like to note that this is still broken for me, if I refresh a documentation page.

@kmoschcau
Copy link

kmoschcau commented Apr 26, 2017

Ok so before I posted my last comment, I updated yard, regenerated the documentation, restarted the yard server, reloaded the page including cache and it did not work.
Now I'm trying it again two days later and it suddenly works.

@thomthom
Copy link
Contributor

thomthom commented Aug 7, 2017

I had hoped that this fixed #1071 - but unfortunately that wasn't the case. Though this thread gives some better clues to where its happening. Something I never found.

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

4 participants