Skip to content

Commit 4920142

Browse files
committed
[css-nav-1] describe spatial-navigation-action in more detail
1 parent 48b3793 commit 4920142

1 file changed

Lines changed: 47 additions & 15 deletions

File tree

css-nav-1/Overview.bs

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,29 +1369,61 @@ Applies to: <a>scroll containers</a>
13691369
Inherited: no
13701370
</pre>
13711371

1372-
When the user triggers spatial navigation in a given direction, the 'spatial-navigation-action' decides
1373-
the proper spatial navigation behavior.
1372+
When the focus is inside of a scroll container and the user triggers spatial navigation,
1373+
it is somewhat ambiguous whether they are requesting that the focus be moved in that direction,
1374+
or whether the document should be scrolled in that direction.
1375+
By default, this is automatically determined,
1376+
but this property allows the author to decide between focusing or scrolling.
1377+
1378+
The precise behavior is defined in [[#nav]],
1379+
but a high level description of the effect of each value is provided below.
1380+
1381+
When spatial navigation is triggered,
1382+
the behavior depends on the value of the 'spatial-navigation-action' on the currently focused element
1383+
if that element is a [=scroll container=],
1384+
or of its nearest [=scroll container=] ancestor if it isn't.
13741385

13751386
<dl dfn-for=spatial-navigation-action dfn-type=value>
13761387
<dt><dfn>auto</dfn>
1377-
<dd>If the element is a <a>scroll container</a>,
1378-
then directional input moves the focus to the candidates in the optimal viewing region.
1379-
When there isn't any visible candidate, then the container scrolls.
1380-
1381-
Otherwise, the focus moves to the candidates in the viewport.
1388+
<dd>
1389+
If there are visible focusable elements within the
1390+
[=scroll container=] in the direction requested,
1391+
the closest one becomes focused.
1392+
Otherwise, the [=scroll container=] is scrolled in the direction requested.
13821393

13831394
<dt><dfn>focus</dfn>
1384-
<dd>The directional input moves the focus to all candidates inside a scroll container. The container <a>cannot be scrolled manually</a>.
1395+
<dd>
1396+
The focus is moved to the nearest focusable element within the [=scroll container=],
1397+
regardless of whether it is visible.
1398+
If there are none,
1399+
the scroll container is <em>not</em> scrolled,
1400+
and the search continues up the ancestry chain instead.
13851401

1386-
NOTE: If the ''spatial-navigation-action/focus'' value is given to 'spatial-navigation-action',
1387-
<a event>navnotarget</a> event occurs when there isn’t any visible candidate in the given direction within the viewport of
1388-
the <a>spatial navigation container</a> even through the container can be scrolled more.
1402+
Note: The [=scroll container=] may be scrolled as a side effect of focusing
1403+
an element which was previously not in view,
1404+
but it will not be scrolled directly.
13891405

1390-
<dt><dfn>scroll</dfn>
1391-
<dd>If the element is a <a>scroll container</a>,
1392-
then directional input only works for manually scrolling the container.
1406+
Note: If the ''spatial-navigation-action/focus'' value is given to 'spatial-navigation-action',
1407+
<a event>navnotarget</a> event occurs when there isn’t any visible candidate in the given direction within the viewport of
1408+
the <a>spatial navigation container</a> even if the container can be scrolled more.
13931409

1394-
Note: The ''spatial-navigation-ation/scroll'' value is <a>at-risk</a>.
1410+
<dt><dfn>scroll</dfn>
1411+
<dd>
1412+
If the currently focused element is not itself a [=scroll container=],
1413+
this value on an ancestor [=scroll container=] has the same effect as ''spatial-navigation-action/auto''.
1414+
1415+
If the currently focused element is a [=scroll container=],
1416+
it is scrolled in the direction requested without changing which element is in focus,
1417+
regardless of the presence of focusable descendants.
1418+
1419+
Note: This means that spatial navigation can be used
1420+
to move the focus to a [=scroll container=] and to scroll it,
1421+
but not to move the focus to its descendants.
1422+
However, if the focus is moved to a descendant by some other mean
1423+
(such as pressing the <span class=key>Tab</span> key or using the <{{HTMLOrSVGElement/focus()}}> method)
1424+
spatial navigation can be used to move the focus to other focusable descendants.
1425+
1426+
Note: The ''spatial-navigation-ation/scroll'' value is <a>at-risk</a>.
13951427
</dl>
13961428

13971429
<div class=example>

0 commit comments

Comments
 (0)