-
Notifications
You must be signed in to change notification settings - Fork 131
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
Adding .sr-only 'skip to content' link #161
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
Why #bodyContent
and not #content
?
It might also be semantically wise to mark the #content
div
as main
instead. Landmark roles make people who use assistive technology, happy!
(Needs the remove tab hijack PR in order to test well)
Not sure, but I do prefer
Updated :) |
Lol. The last commit didn't load for me! But now it has, and you figured it out :P. |
@MikeRogers0 could you squash the commits? |
@p8 - Done :) But also +1 on "Squash and Merge", I use that on all my projects & I love it! |
@SleeplessByte @MikeRogers0 Thanks 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know for sure if this is the syntax required to disable turbolinks, but see the behaviour on those two links.
- Click the search box
- Shift + Tab (reverse tab) should show Skip to content
- Follow the skip to content link
- Press Tab
In the correct behaviour it now focuses the first link on the right hand side. Here it worked. In the incorrect case it now shows the skip to content link again, which means that #content
wasn't focussed, but body
was.
Weird. I looked up the docs and |
@SleeplessByte That's a really odd issue! But I figured out the cause! At first I thought it might be the older version of Turbolinks, then I thought the inline JavaScript in the I'm going to look more closely with fresh eyes tomorrow :) |
@MikeRogers0 feel free to ping me too if you need or want a review once this is ready |
I've not forgotten about this PR, I'm still trying to figure out why clicking the anchor link is trigging a full page refresh in Turbolinks :) |
panel.toggle(<%= tree_keys %>); | ||
} | ||
}) | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was adding a new listener each page view, so I moved it into the main.js
, passing in the contextual data via meta tags.
@@ -63,6 +63,7 @@ Searchdoc.Navigation = new function() { | |||
} | |||
break; | |||
case 13: //Event.KEY_RETURN: | |||
if(e.target.dataset["turbolinks"]) { break; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix I had for the pages reloading when the "skip to content" was clicked via a keyboard user. Pretty much, before if a user was navigating via the keyboard the JS would think they're interacting with the search, and it caused a re-render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Yes. Turbolinks does stuff like that :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find 😄
I figured out what was causing the double navigating issue. @SleeplessByte could you verify this solves the issue? :) |
It seems to have solved everything except that I now don't know how to search if I'm only using my keyboard 😅 . Is there a shortcut to press? |
@SleeplessByte - Oh gosh, yeah I can imagine that would be annoying. Do you think a "Jump to Search" link/label would solve that? |
@MikeRogers0 Github and Twitter use "/" for search (as do a lot of commandline apps). |
The current shortcut for search is CTRL+s |
I would probably add this to the search placeholder (search, type / to start searching) and perhaps add it to a sr-only thing right after the skip to navigation. So people can skip the search message, but could still reach it 😬 |
@MikeRogers0 Weird. If I'm opening the latest netlify preview the search input is focussed again by default. |
@p8 - I did a hard refresh & I'm seeing that also 🤔 |
if(!$('#panel .tree ul li').length) { | ||
$('#links').hide(); | ||
var panel = new Searchdoc.Panel($('#panel'), search_data, tree, '<%= rel_prefix %>/'); | ||
$('#search').focus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LOC was causing the refocus when I moved this over to be in main.js
. I removed the focus @p8 in the latest version.
After adding these, I ran into some fun JS related errors where we'd benefit moving things, along with the SearchDoc interfering with Turbolinks. Setting sidebar to be a <nav> as that's its purpose - Let's see how that helps with SEO. Hinting more clearly we have a key command for quick searching (and adding support for / )
@p8 - Solved it! We had a I think this is ready now. |
@MikeRogers0 Can you provide some instructions on how to test this? I haven't been following too closely and there's a bunch of different screenshots :) |
@zzak I've updated the PR description to be a bit more clearer https://github.com/zzak/sdoc/pull/161#issue-607671522 :) I also just recorded a video on what it does ( https://www.youtube.com/watch?v=RbXg8BLSDpY ) :) |
@MikeRogers0 I just tried it out and it's ✨ wonderful! |
@SleeplessByte I think collapsing that header would be useful as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll wait for @zzak but this looks great to me.
After it's merged I can do a new release and PR to Rails.
@MikeRogers0 Thanks for your hard work on this and the YT video was very helpful! @p8 Feel free to merge + release at your convenience 🙇 |
I've released 2.2.0 and made a PR for Rails: |
Issue https://github.com/zzak/sdoc/issues/158
Description
This adds a link to the top of each of the pages with "Skip to content" as the text which is activated by tabbing through the site, when clicks it, it should take the user to the
#content
<div>
. The CSS is taken from Bootstrap 4.Preview
Also video on YouTube demoing this
Testing
Skip to content
Chrome is the easiest to verify with, open the preview app & press "tab", a link saying "skip to content" . When you press "return" it should just the focus (and tab index) to the content.
Search
Press
/
to quickly start searching, this is similar to before where we hadCTRL + S
but is more inline with other big sites approaches.