Friday, February 26, 2016

Can JavaScript set a Sequential Focus Navigation Starting Point?

This is a follow-up from my last blog post. Should a web author be able to explicitly set a Sequential Focus Navigation Starting Point using JavaScript?

There are several reasons why the answer should be "yes."

It can improve user experience in some cases

Today, for accessibility it's often necessary to set focus on a div or static text. If browsers and assistive technologies will provide a consistent experience for anchor links, then instead of setting focus on non-actionable content, it would be more like native browser behavior to set a Sequential Focus Navigation Starting Point. In such cases users would expect to see the element in the viewport, so the author should also use Element.scrollIntoView().

Less often, this same technique can solve a usability problem when JavaScript sets focus on a text input. In devices with virtual keyboards (iOS Safari at least), input.focus() causes the virtual keyboard to appear. This is appropriate in some cases, where the design intent is to strongly prompt the user to enter something. But what if the intent is only to start the user at a logical spot in the form? For example, after the user cancels out of a modal dialog. In this case using JavaScript to set a Sequential Focus Navigation Starting Point would provide a better experience.

It conforms to WCAG 2.0 as well as anchor links do

I've never heard of failing Success Criterion 2.4.3 Focus Order or 2.4.7 Focus Visible because of the browser-default behavior of anchor links. This JavaScript technique would do the same thing.

There are good technical precedents

Setting window.location.href creates the same effect as a user clicking a link to a new page.

In most browsers, Element.focus() creates the same effect as a user clicking an anchor link to land on a focusable element.

So if JavaScript can create the effect of an anchor link landing on a non-focusable element, it would be very consistent with those existing capabilities.

It might already work

When an element has focus, then the expected behavior of Element.blur() -- after Chromium issue 454172 -- is to create a Sequential Focus Navigation Starting Point.

So what should happen if the author invokes Element.blur() on an element that does not currently have focus? The logical consequence would be for this element to become the Sequential Focus Navigation Starting Point.

I could live with this counterintuitive behavior of Element.blur(), like we've all learned to live with tabindex="-1". I'm also open to adding a more aptly named method to browser-native JavaScript.

Tuesday, February 23, 2016

The "sequential focus navigation starting point" in WebKit and Chromium

Both from a user perspective and from a technical perspective, I like the way Chromium is formalizing the "sequential focus navigation starting point".

A few highlights of this change:
If a navigation to a url with fragment identifier happened, an element pointed by the fragment is set as sequential focus navigation starting point.
In other words, anchor links like #skip_to_main will now work for keyboard users, without any JavaScript. We've only been waiting for this since 1990!
If the element pointed by sequential focus navigation starting point is removed from the document tree, a point where there was the element at would be the starting point.
This is good for accessibility in modern web sites, such as single-page apps. We'll first need to see some follow-on improvements in browsers and assistive technologies, but eventually this might allow web authors to simplify focus management, as DOM elements are removed and changed.
Implementation: Sequential focus navigation starting point is represented as a Range object, and it is owned by a Document.
This is the technically elegant part. It builds on existing patterns, to achieve something new.

Now I have a few questions for the community. The behavior is already looking good for users, so these questions are mainly geared toward supporting web authors.
  1. There's a standard and widely supported Range object. What's the interface to access this new special Range? Maybe as a property of the Document?
  2. The related WebKit ticket points out that Gecko (Firefox) and Trident (Internet Explorer) already have their own implementations. Can this interface be standardized across browsers, or is it too late for that?
  3. As the Chromium issue points out, there are several kinds of scripted behaviors and user behaviors which cause the Sequential Focus Navigation Starting Point to occur. Although not mentioned specifically, presumably the point could change any number of times before any DOM element gets focus. Given that these various behaviors all lead to a single thing happening from a user perspective, could we fire a device-independent JavaScript events? It would be a mouthful -- "onSequentialFocusNavigationStartingPointChange" (?!?) -- but you get the idea.
  4. Would it make sense for this Range object to be the relatedTarget of blur events?
Finally, I have a couple of more questions that are geared toward making life easier for developers of browsers and assistive technologies.
  1. Is there a consistent behavior in browsers for caret navigation?
  2. What are the use cases for mobile browsers?
  3. Similar to the JavaScript event questions -- can there be a related event in accessibility APIs? Screen readers have tried to compensate for browser differences, but this could lead to more consistency in the future.

Saturday, January 17, 2015

Raw notes while reading Paul's book

Here's some decidedly gray literature: my raw notes about Paul Saint-Amour's new book.

Reaching page 6, I was struck by a hypothesis: people's tendency to underestimate the likelihood of unlikely negative events, although irrational, is nevertheless adaptive.

Reaching page 9:

What about Carthage? What about Vietnam?

In the more recent modern era, have people found new strength from being targeted by total war or by a merciless or indiscriminate enemy with massive destructive capability? Namely, the clarity of the choice to fight when flight is no option. Or is there nothing recent about that response, other than new technological means of responding -- the tools of what we call terrorism?

Back to page 8, footnote:

maybe later I’ll look up "perdure" and "sequelae"
(earlier I looked up "frisson", and "index" as a verb)

noting his use of scare quotes: "conventional" wars

transgenerational injury -- are the long-term effects of America's slavery another example?

somewhere in here… “longue durĂ©e”

page 10:

"unprecedented proliferation and destruction of written records" -- DARPA anticipated the need for communication resiliency, and created internetworking. (Did I get this history right?) Organizations like Archive.org and Long Now noticed the fragility of our digital information riches. I wonder how well we are collectively doing at their goals.

page 11:

I’m reflecting now on how Paul took ten years to create this. Maybe I should work on a project or two like that.

page 14:

Will these encyclopedic works be the only suggestion of hope? What about the optimism of literally designing or inventing the future?

page 16:

I’m skimming now.

I’m interested in how the subcortical parts of the brain give rise to these responses to war, and how the cortex attempts to integrate them into a concept of reality.

Ah, here we go, application to today.

By the way: a few of us saw through the Threat Level from the start. (The colors were transparent.)

All this about anticipation. We could use some Landmark Education here: be -> have -> do. Of course we put our past into our future, but it’s a choice.

Page 19:

I notice I’m biased against Freud, and against the language of literary criticism.

Page 20:

So far I’m seeing too much focus on fear of one’s own death. What about caring for others? Seeing harm inspires some to love more generously.

Page 21:

I’m emboldened to be smart. Yet I’m also reminded of the feeling of when Ben beat me twice at Countermine: it can feel uncomfortable in the presence of towering intellect. Do I want others to feel that?

Page 22:

I googled and found “counterfactual history”

“What if… the debris left by the catastrophe of history were partially constituted of futures seen by the past as barred?” I’m getting it, it’s sinking in. To me, this is very hopeful.

I should note what I’ve been reading:

Page 23:

I agree. Contemporary dialog about global warming is certainly evidence that a population’s views of the future can influence historically significant events in the present.

That's all Google Books will let me read for free. Ah well, it's probably enough fun for me.