NVDA Skips first focusable element on initial page load when tab pressed - html

Recently while attempting to make my site accessible I stumbled upon a bizarre problem. During the process of setting up a 'skip navigation' link, I noticed that when the page is initially loaded (by 'initially loaded', I mean in a clean browser session, not on refresh—as NVDA keeps a track of the last focused element so results would be dependent on that).
When the page loaded and the tab key pressed, the element that received focus was the 2nd element (which as you will see from the below simplified example, is the site logo/name (also an anchor link)).
The problem doesn't show when NVDA is not running... everything works as expected, Firefox works perfectly fine with or without NVDA running but the problem is present in Chrome, Edge and Opera desktop. I've not tested it on any other browsers thus far.
Please note, because of the nature of the problem, I didn't include a runnable code snippet or fiddle (as there would be other elements on the screen and, as I said this problem only shows with a new browser session/clean page load. Here is some simplified code to show the problem...
CSS
body, html {
margin: 0;
}
.skip-nav {
position: absolute;
margin: 10px 0 0 10px;
white-space: nowrap;
display: inline-block;
padding: 0;
}
.skip-nav a {
position: absolute;
left: -1000px;
border: 2px solid blue;
border-radius: 2px;
background-color: black;
padding: 5px;
}
/* Move link into viewport when focused */
.skip-nav a:focus {
left: initial;
}
nav {
display: flex;
align-items: center;
justify-content: space-between;
height: 30px;
background-color: darkblue;
padding: 10px;
color: white;
}
nav ul {
list-style: none;
}
nav li {
display: inline;
margin: 0 5px 0 5px;
}
a {
text-decoration: none;
color: white;
}
a:hover {
color: rgb(165, 165, 165);
}
HTML
<!-- Should get focus first, only does in FF when NVDA is running, not in other tested browsers -->
<div class="skip-nav">
Skip navigation
</div>
<!-- Dummy nav bar -->
<nav>
Name
<ul>
<li>Home</li>
<li>Services</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<!-- Main site content -->
<section id="main-content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Animi dolores voluptates temporibus culpa in quia et magni laborum architecto fugit!
</section>
Things I have tried
The first thing I did was to disable all my browser extensions/test in Chrome incognito mode. Then I tried in the other browsers mentioned above. I also tried other focusable elements (such as a button and even a div with the 'tabindex=0' attribute set. I also put my initial link on its own (not within a parent div). All gave the same results.
Workaround
Instead of placing the link in a div, I put it in an ul/li... and it works perfectly...
<!-- Using a UL works... but not with bullets hidden
<ul class="skip-nav">
<li>
Skip navigation
</li>
</ul>
So I thought I would just set the list with the following property in my CSS...
list-style: none;
The bullet disappears but the problem returns...
For now, I've stuck with the 'fix', but instead of setting the list-style to none I've simply removed the padding from the list so that when it's over to the left side of the screen, the bullet remains off-screen and hidden. I've tested this in all browsers and it works, save for the fact that screen readers still read and announce the 'bullet' when traversing elements (in NVDA, using the arrow keys). Not a massive deal-breaker but this seems a very 'hacky' way of achieving (something close to) the desired result.
Just to summarise, to reproduce the problem the browser must be a new session. With the page loaded, the first tab press should focus the link in the 'skip-nav' div. Currently with the above example the initial tab seems to ignore the first link (unless in a bulleted list). However, shift-tabbing backwards then does focus the link as would be expected.
Is there something I'm missing?

This is a visual focus problem, when you load the page focus is placed on the document (by the browser) and the first link is already focused (by NVDA) if it isn't wrapped in a <ul>. NVDA also doesn't report that the item is focused using NVDA + Tab.
However if you press Space to activate the link you will see it is indeed focused as the URL updates.
My guess is it is something to do with how NVDA places the review cursor when focus changes programatically and how it interacts with the first item on the page.
Also if you put focus into the URL bar after the page loads (resetting the focus) and Tab into the document it behaves as expected.
This appears to be a long standing bug but I couldn't find any answers as to what particular part of the process causes this. It is also a bug I was unaware of until today so I will do some more digging (my sites are affected by this).
The only thing I can think is that the browser focuses the document the first link on the page is the first text and when the review cursor is placed on it it assumes that the link is activated (or focus is set by NVDA before the document is rendered...pure conjecture though).
How to fix for yourself
One way around this is to change your settings in NVDA.
Right click NVDA icon -> Preferences -> Review cursor... -> uncheck "Follow system focus".
At that point you will see that the first item on the page is automatically focused correctly.
How to fix for everyone else
It is debatable whether it needs fixing, Tab is not used as often as other methods by screen reader users and with the fact it is only on a brand new session (I mean I have never noticed it and I use a screen reader often, albeit only for testing not as a full time user) I imagine most people will not be affected.
As it only appears to happen if the first text on the page is a link you could work around it perhaps (I haven't had chance to test) by adding a span before it with a space.
<div class="skip-nav">
<span> </span>
Skip navigation
</div>
I will return to this question after some testing of the above but it may take a couple of days before I get chance.
Update
I was correct it seems, adding a span with a space fixes the issue and focus is shown correctly.
full HTML tested in the fiddle below, just added <span> </span> into the <header>, the first link then shows focus as expected:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NVDA focus Test</title>
</head>
<body >
<header>
<span> </span> <!---------------THIS IS WHAT I ADDED------------->
I should focus on first tab press
I should focus on second
</header>
<section style="margin-top: 20px;">
<p>
When you press tab after this page has loaded (at least for me), the initial tab press will focus the <i>second</i>
link for some reason.
</p>
<p>
This seems to happen however I present the link (on its own, wrapped in a div, section, or even a ul/li with the
list-style set to 'none') :-(.
</p>
</section>
</body>
</html>

Related

unexpected effects of two sections being :target at once after change of device in FF

I have developed page of simplified shape like this:
<html>
<head></head>
<body>
<nav></nav>
<main>
<section id ="Introduction"></section>
<section id ="aboutme"></section>
<a href="#Introduction">
<span class="triangle__more">
<img src="./assets/up-arrow.svg" alt="arrow up" />
</span>
</a>
</main>
<body>
</html>
with css:
.section {
#include clearfix();
min-height: 100vh;
width: 100%;
position: relative;
display: none;
&:target {
display: block;
}
The problem is, that if I do steps like this:
open the page with laptop on real laptop
change section to #aboutme with menu(no menu details here)
change device in Inspector to any of small-screen devices
change section to #Introduction with link in the bottom
I have both sections active(displayed) and not only #Introduction (what was my expected result).
I have also noticed that changing only screen size or orientation (and not device) does not lead to that unwelcome effect.
Could someone explain to me why it happens (is that purely FF Inspector issue)? And whether I can feel safe with that code in real life (where no-one changes device during session).
OK, finally, I think it is Firefox console bug rather. I have checked with other browser, and it is OK. Besides - when I only change the viewport wide by numbers - is OK. It really happens only when I switch device. Hopefully quite an unusual in real life.

Transform translate has wierd behavior on keyboard focus in Chrome

I am developing a navigation side bar which should show some data when closed, and the reveal it all when hovered or focused via keyboard navigation (just using the tab button in this case). It works by having an inner container which I translates opposite of the outer container thus being able to show some content even when it is closed. It works perfectly fine when hovering, but when navigated to with keyboard events (tab button), the inner container suddenly translates itself the wrong place. If I remove and apply the translate class again on the inner class it translates back to where it should.
I find it weird that the inner container just translates itself on focus. And even weirder that it does not seem to be reflected in the CSS of the element, that I can just remove and reapply the same class and then it works.
A minimum reproducible example is found here: https://codepen.io/kasperlauge/pen/dyoaxKJ
Code for this is:
HTML:
<h1>Hover this list to reveal more...</h1>
<div class="outer">
<div class="inner">
<button type="button">abcdefghijklmnopqrstuvxyz</button><br/>
<button type="button">abcdefghijklmnopqrstuvxyz</button><br/>
<button type="button">abcdefghijklmnopqrstuvxyz</button><br/>
<button type="button">abcdefghijklmnopqrstuvxyz</button><br/>
<button type="button">abcdefghijklmnopqrstuvxyz</button><br/>
<button type="button">abcdefghijklmnopqrstuvxyz</button>
</div>
</div>
CSS:
.inner, .outer {
width:200px;
overflow:hidden;
transition:all 0.3s;
}
.inner {
transform:translateX(150px)
}
.outer {
transform:translateX(-150px);
background-color: #BBB;
padding: 10px;
}
.outer:hover,
.outer:hover .inner {
transform:translateX(0)
}
When not hovered/focused:
When hovered (right behaviour):
When tabbed to (wrong behaviour):
Can somebody help?
I actually did solve it for my case, but unfortunately it does not generalize to the codepen provided in the question, thus I still would like to see a good solution to that in Chrome and Edge, as Firefox do not generate the faulty scrolling.
The way I solved it in my case was by reducing the width of the buttons to make them fit within the non revealed stuff. It works in our case because we have three states of revealing in our menu and it only have to fit within the two first states.

HTML put an icon in front of webpage

Until now I got a webpage with a navigation bar, which is responsible to screensize, all is fine until this point.
But now it becomes a bit strange for me, I want to add a search icon (loupe) in the bottom left hand corner. My idea was to use the "aside" element (or "aside" section?) which is supported in html5, but if I put my icon in this aside element it is not visible. I hope you can help me. here some html code:
HERE IS SOME OTHER CODE WHICH WORKS PERFECT
.
.
.
<!-- Search Icon beginn -->
<aside>
<div class="searchicon">
<img src="img/Searchicon.png" alt="Search" height="30px" width="30px">
</div>
</aside>
<!-- Search Icon end -->
</body>
My plan is that the search icon is always on the left of the webpage (kind of a sidebar), I don't want to cover up the text which is at the site later on.
Thanks to you!
Try changing the z-index in css which will basically move an HTML element forward/backward :
.searchicon {
z-index: 2;
}
/*
Set the value to negative if you want the element to move backwards.
*/
The positioning of HTML elements is controlled in your CSS. In your case this is the searchicon class. You haven't provided the CSS but it might look something like this:
.searchicon {
position: fixed;
left: 150px;
bottom: 150px;
z-index: 2;
}
As a note, the aside element may not be the "most semantic" option based on what you've described. The HTML5 aside is intended to contain content that doesn't directly relate to the pages primary content. For example a sidebar containing related articles.

Unable to see entered text in the input field in IE11 browser

I'm using clarity ui framework for building the website. I have added some additional padding on top of the clarity ui input field. It's seems working in all browsers except in IE11 where I'm unable to see the entered text. What changes do I have to make in order for the text to appear in the input field?
Here is the stackblitz link to get access to the code
https://stackblitz.com/edit/clarity-forms-test-ea75jb?file=src%2Fapp%2Fapp.component.css
<div class="clr-control-container">
<div class="clr-input-wrapper">
<input type="text" id="example" placeholder="Example Input" class="clr-input">
</div>
</div>
Styles
input[type] {
background-color: grey;
padding: 21px 6px; //Adding padding is the reason causing the issue
color:white;
width: 100%;
margin-top: 5px;
}
Is there any workaround for this issue?
I try to check the code using developer tools and and I find that _ngcontent-c0 causing this issue.
If you remove it from the code than you can able to see the test in the text box in IE.

2 Links + Button not positioning correctly in IE7/8/9 like they do in Chrome/Firefox

I have a .jsp file that we use as a login page at https://com-bb-dev.com.edu and in that file it has a few lines laying out some links/buttons and a live chat button.
<h2><center>Accessibility Options</center></h2>
<ul>
<access class="access">
<img src="/images/ci/ng/fonts.gif" alt="" />
<a href="#" title="Change Text Size"
onClick="page.showChangeTextSizeHelp()">Change Text Size</a>
</access>
<access class="access">
<img src="/images/ci/ng/contrast.gif" alt="" />
High Contrast Setting
</li>
</access>
</ul>
<div id="parature">
<parature>
<a id="b2b8839e-6318-4c34-9863-9071b06192f3" href="javascript:void(0);" onclick="return launchChatWindow('http://com.parature.com/ics/support/default.asp?deptID=15028&task=chat&deploymentId=b2b8839e-6318-4c34-9863-9071b06192f3');"></a>
<script src="http://com.parature.com/ics/csrchat/inc/chatDeployment.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = createDplOnLoadDelegate('b2b8839e-6318-4c34-9863-9071b06192f3', 'com.parature.com', 15026, 15028, window.onload, true);
</script>
</parature>
</div>
Up within that same file I have declared some separate styles so that I can modify them without affecting anything else that is in the same . Here is what I declared:
parature
{
float: right;
margin-right: 18px;
position: relative;
bottom: 30px;
width: 138px;
}
access
{
display: inline-block;
margin: 0px -4px 6px;
font-size: 125%;
padding-left: 24px;
}
Of course, this works fine and the buttons and links display properly in Firefox and Chrome. And to my horrid dismay it does not work in IE8. You'll see that the button is treated as a direct down-the-line item and that the two links under accessibility options to not take on any CSS formatting. Is it because they are using styles that I declared locally in the .jsp page? I've already had to go back and discover that the ancient fossil didn't support transparency so that was fun to discover and fix. This is what I've tried so far:
parature
{
float:right;
width: 138px;
}
Because I read that floats don't work if the div doesn't have a width. Not sure what to look for. The IE8 developer pane is a total nightmare.
Thanks.
You are attempting to use custom elements, which you shouldn't be doing, but IE, specifically, will not style any elements it is not aware of. That would include every non-standard element you are attempting to use now.
This can be done using javascript. Google for "html5shim" for an example of how IE is updated to accept HTML5 elements.
EDIT: In addition, the elements you are using inside the ul are invalid since ul can only contain li elements.
There's no opening tag for the li. That could be the problem. If not, you might try using an inline-block on the parature class just to see if the block will render on the page.