I'm creating interactive fiction in HTML. The user is presented with a list of paragraphs and then a series of choices and when they select a choice, the list of choices is removed and replaced with the new content. But, the selected choice is left in as a reminder and to provide a way for the user to return and make a different choice.
Here's the markup before the user selects a choice:
<div aria-live="polite">
<p>You enter the castle.</p>
<p><button>Go to throne room</button></p>
<p><button>Go back out</button><p>
</div>
And here's the markup, edited by jQuery, after the user chooses "Go to throne room":
<div aria-live="polite">
<p>You enter the castle.</p>
<p class="reminder">Go to throne room (<a>click this to make a different choice</a>)</p>
<p>There is a king in the room!</p>
<p><button>Assassinate him</button></p>
<p><button>Talk to him</button></p>
</div>
Now, when I press Tab to move to the next element, the link "click this to make a different choice" gets selected which is almost never going to be useful. In the most common case, the user would want to select between the options in the next choice, so I would like the first Tab after choice to select "Assassinate him".
Similarly, after a choice, NVDA starts reading the reminder text first, which I would also like to skip, and have it start reading "There is a king in the room!" instead, since the user already knows what choice they made.
I don't want to remove the text and link from tab order and screen reader completely, just skip it once when the content is created.
Can this be done?
You may want to look at structuring the page differently.
aria-liveshould be used for announcements that are out of the document flow (things like alerts, save confirmations, updates etc.)For your purposes you do not need
aria-livebut instead want to implement focus management.So your page flow would be as follows:-
The second point is the key point, you probably want to focus something that is not normally focusable (and you do not want it in the document focus order.). To do this you combine
tabindex="-1"and.focus().tabindex="-1"basically allows something to received programmatic focus (using your JavaScript.focus()function) but it will not get added to the focus order of the page (you cannot use Tab to focus it).I have put together a very ugly demo below to demonstrate the behaviour (I haven't included the change choice etc. but you should get the idea):