From df208432d29e27e622d4c79499e894812b5d979d Mon Sep 17 00:00:00 2001
From: Jihye Hong ArrowDown key moves focus to
+ Pressing the ArrowDown key moves the focus to
"Box 3" without scrolling because "Box 3" is visible in the scrollport of the spatial navigation focus container.
@@ -321,7 +321,7 @@ User Agents should offer a means for users to trigger spatial navigation directl
without having to use the APIs.
Note: Conversely, authors should assume that spatial navigation may be triggered
-by the UA in response to user actions
+by the User Agent in response to user actions
even if the author has not invoked any of the APIs.
Regardless of the actual mechanism chosen to trigger spatial navigation,
@@ -370,7 +370,7 @@ the following requirements apply:
(in addition to moving the focus)
User Agents should not offer the same mechanism to trigger both spatial navigation
and a scrolling behavior separate from spatial navigation.
- UAs may however, offer a way for the user to switch between different modes,
+ User Agents may however, offer a way for the user to switch between different modes,
or offer both based on different UI mechanism.
ArrowRight
key.
For the sake of keeping the description simple,
- this example assumes a UA where spatial navigation is triggered using arrow keys.
+ this example assumes a User Agent where spatial navigation is triggered using arrow keys.
@@ -760,7 +760,7 @@ and it cannot be scrolled at the same time.
This example shows the [[UI-EVENTS#event-order]] when pressing the
ArrowDown
key in the situation like the following figure.
For the sake of keeping the description simple,
- this example assumes a UA where spatial navigation is triggered using arrow keys.
+ this example assumes a User Agent where spatial navigation is triggered using arrow keys.
@@ -946,7 +946,7 @@ The user agent may set it when the user indicates that it should be moved.
Note: For example, the user agent could set it to the position of the user's click if the user clicks on the document contents,
and unset when the focus is moved (by spatial navigation or any other means).
-If the UA sets both a spatial navigation starting point and a sequential focus navigation starting point,
+If the User Agent sets both a spatial navigation starting point and a sequential focus navigation starting point,
they must not be set differently.
'all',
or true otherwise.
2. Let areas be the result of finding focusable areas within the element with the visibleOnly argument.
-3. Loop: If there is a spatial navigation container container among areas,
- then add the result of finding focusable areas to areas within the container.
-5. Let anchors be a clone of areas,
+3. Let anchors be a clone of areas,
with every focusable area which is not itself a Node replaced with its DOM anchor.
-6. Return anchors
+4. Return anchors
null,
or the element's nearest spatial navigation container ancestor
-4. Return the result of selecting the best candidate within areas in direction d from the element
+3. Return the result of selecting the best candidate within areas in direction d from the element
Note: When neither a container nor a list of candidates is provided,
this only searches through the visible focusable areas of the nearest
spatial navigation container ancestor.
-If none are found, this does not climb further up the ancestry chain,
+If there isn't any eligible element to navigate, this does not climb further up the ancestry chain,
and the result will be null.
null.
the focus is automatically transferred to it.
- document.addEventListener("navbeforefocus", function(e) {
+ document.addEventListener('navbeforefocus', function(e) {
e.preventDefault();
- if (e.dir === "forward" || e.dir === "backward") {
- e.dir = "top";
- }
-
- var t = e.relatedTarget;
- while (t.isSameNode(t.getSpatialNavigationContainer())) {
- var areas = t.focusableAreas();
+ let target = e.relatedTarget;
+ while (target.isSameNode(target.getSpatialNavigationContainer())) {
+ const areas = target.focusableAreas();
if (areas.length === 0) { break; }
- t = t.spatialNavigationSearch({
+ target = target.spatialNavigationSearch({
dir: e.dir,
candidates: areas
});
@@ -571,44 +565,45 @@ and the result will be null.
- document.addEventListener("navnotarget", function(e) {
+ document.addEventListener('navnotarget', function(e) {
e.preventDefault();
- var c = e.relatedTarget;
- var areas = c.focusableAreas({mode: "all"});
+ const container = e.relatedTarget;
+ const areas = container.focusableAreas({mode: 'all'});
if (areas.length === 0) {
switch (e.dir) {
- case "down":
- c.scrollTop = 0;
+ case 'down':
+ container.scrollTop = 0;
break;
- case "up":
- c.scrollTop = c.scrollHeight;
+ case 'up':
+ container.scrollTop = container.scrollHeight;
break;
- case "right":
- c.scrollLeft = 0;
+ case 'right':
+ container.scrollLeft = 0;
break;
- case "left":
- c.scrollLeft = c.scrollWidth;
+ case 'left':
+ container.scrollLeft = container.scrollWidth;
break;
}
} else {
- var t = c.spatialNavigationSearch({
+ const target = container.spatialNavigationSearch({
dir: e.dir,
candidates: areas
});
- t.focus();
+ target.focus();
+ }
});
<body>
- <button class="box" style="top:100px; left:20px;"></button>
- <div class="container" style="left:110px; width:300px; height:200px; overflow-x: scroll;">
- <button class="box" style="top:78px; left:25px;"></button>
- <button class="box" style="top: 80px; left:150px;"></button>
- <button class="box" style="top: 80px; left:350px;"></button>
+ <button class="box"></button>
+ <div class="container" style="width:300px; height:200px; overflow-x: scroll;">
+ <button class="box" style="left:25px;"></button>
+ <button class="box" style="left:150px;"></button>
+ <button class="box" style="left:350px;"></button>
</div>
</body>
- const focusableAreas = document.body.focusableAreas({'mode': 'visible'});
+ const focusableAreas = document.body.focusableAreas({mode: 'visible'});
focusableAreas && focusableAreas.forEach(focusable => {
focusable.style.outline = '5px solid red';
});
@@ -522,13 +524,13 @@ The {{Element/focusableAreas()}} method must follow these steps:
null,
then let areas be that attribute,
else, let areas be the result of finding focusable areas
within the argument's {{SpatialNavigationSearchOptions/container}} attribute is not null,
or the element's nearest spatial navigation container ancestor
-3. Return the result of selecting the best candidate within areas in direction d from the element
+3. Return the result of selecting the best candidate within areas in direction direction from the element
Note: When neither a container nor a list of candidates is provided,
this only searches through the visible focusable areas of the nearest
@@ -551,14 +553,14 @@ and the result will be null.
while (target.isSameNode(target.getSpatialNavigationContainer())) {
const areas = target.focusableAreas();
- if (areas.length === 0) { break; }
+ if (areas.length === 0) { target.navigate(e.dir); }
target = target.spatialNavigationSearch({
dir: e.dir,
candidates: areas
});
}
- t.focus();
+ target.focus();
});
bubbles and cancelable attributes set to true,
- and return if the result is false
+ fire an event named navbeforefocus at eventTarget using {{NavigationEvent}} with:
+ * Set {{NavigationEvent/dir}} to direction
+ * Set {{NavigationEvent/relatedTarget}} to bestCandidate
+ * Set bubbles and cancelable attributes to true
+
+ and return if the result is false.
3. Run the focusing steps for bestCandidate and return
* Else if eventTarget can be manually scrolled, directionally scroll the element
eventTarget in direction and return.
@@ -983,9 +987,11 @@ To run the spatial navigation steps in direction, do the f
container in direction and return.
* Else,
1. If navigation-override is enabled in the [=node document=] of eventTarget for the origin of the [=active document=] of the [=top-level browsing context=], then
- fire an event named navnotarget at eventTarget using {{NavigationEvent}}
- with its {{NavigationEvent/dir}} set to direction and {{NavigationEvent/relatedTarget}} set to container
- and with it's bubbles and cancelable attributes set to true,
+ fire an event named navnotarget at eventTarget using {{NavigationEvent}} with:
+ * Set {{NavigationEvent/dir}} to direction
+ * Set {{NavigationEvent/relatedTarget}} to container
+ * Set bubbles and cancelable attributes to true
+
and return if the result is false.
2.
* If container is the document element of the top-level browsing context,
@@ -999,13 +1005,15 @@ To run the spatial navigation steps in direction, do the f
* Else, set container to its closest ancestor that is itself a spatial navigation container
and return to the step labeled loop.
9. Let bestCandidate be the result of selecting the best candidate
- within candidates in direction starting from searchOrigin
+ within candidates in direction starting from searchOrigin.
10. If navigation-override is enabled in the [=node document=] of eventTarget for the origin of the [=active document=] of the [=top-level browsing context=], then
- fire an event named navbeforefocus at eventTarget using {{NavigationEvent}}
- with its {{NavigationEvent/dir}} set to direction and {{NavigationEvent/relatedTarget}} set to bestCandidate
- and with it's bubbles and cancelable attributes set to true,
- and return if the result is false
-11. Run the focusing steps for bestCandidate and return
+ fire an event named navbeforefocus at eventTarget using {{NavigationEvent}} with:
+ * Set {{NavigationEvent/dir}} to direction
+ * Set {{NavigationEvent/relatedTarget}} to bestCandidate
+ * Set bubbles and cancelable attributes to true
+
+ and return if the result is false.
+11. Run the focusing steps for bestCandidate and return.
null,
- then let areas be that attribute,
- else, let areas be the result of finding focusable areas
- within the argument's {{SpatialNavigationSearchOptions/container}} attribute is not null,
- or the element's nearest spatial navigation container ancestor
-3. Return the result of selecting the best candidate within areas in direction direction from the element
+ then let areas be that attribute.
+3. Else, let container be
+ * the argument's {{SpatialNavigationSearchOptions/container}} attribute, if it is not null,
+ * the element's nearest spatial navigation container ancestor, otherwise.
+4. Let areas be the result of finding focusable areas within container.
+3. Return the result of selecting the best candidate within areas in direction direction from the element.
Note: When neither a container nor a list of candidates is provided,
this only searches through the visible focusable areas of the nearest
@@ -1011,7 +1012,7 @@ To run the spatial navigation steps in direction, do the f
* Set {{NavigationEvent/dir}} to direction
* Set {{NavigationEvent/relatedTarget}} to bestCandidate
* Set bubbles and cancelable attributes to true
-
+
and return if the result is false.
11. Run the focusing steps for bestCandidate and return.
@@ -1116,7 +1117,7 @@ run the following steps:
2. If closest subset contains a single item,
return that item,
else return the first item of closest subset in document order,
- unless its [=boundary box=] overlaps with the [=boundary box=] of an other item
+ unless its [=boundary box=] overlaps with the [=boundary box=] of another item
and that item is higher in the CSS [=painting order=].
In that case, return that item instead,
unless it too is overlapped with another higher item, recursively.
@@ -1147,14 +1148,14 @@ run the following steps:
To calculate the distance, the function is defined as below:
- distance = euclidian + displacement - alignment - sqrt(Overlap)
+ distance = euclidean + displacement - alignment - sqrt(Overlap)
The meaning of each factor in the function is as follows:
-
table { spatial-navigation-contain: contain; } to the stylesheet
- would result it this behavior.
+ would result this behavior.
It would still be possible to move the focus out of the table,
for example by going right from "Foo".
Since there is nothing in the grid that is to the right,
From 184b7b03ef0db378ec8cdca58612d1ca8f985288 Mon Sep 17 00:00:00 2001
From: Jihye Hong
-[Constructor(DOMString type, optional NavigationEventInit eventInitDict)]
+[Exposed=Window,
+ Constructor (DOMString type, optional NavigationEventInit eventInitDict)]
interface NavigationEvent : UIEvent {
- readonly attribute SpatialNavigationDirection dir;
- readonly attribute EventTarget? relatedTarget;
+ readonly attribute SpatialNavigationDirection dir;
+ readonly attribute EventTarget? relatedTarget;
};
dictionary NavigationEventInit : UIEventInit {
- required SpatialNavigationDirection dir;
- EventTarget? relatedTarget = null;
+ SpatialNavigationDirection dir;
+ EventTarget? relatedTarget = null;
};
From 9ef245b41dd99f723d63c55791f11353dfaca6a1 Mon Sep 17 00:00:00 2001
From: Jihye Hong false
- if the argument's {{FocusableAreasOptions/mode}} attribute is present and equal to 'all',
+ if option is present and it's value is equal to 'all',
or true otherwise.
-2. Let areas be the result of finding focusable areas within the element with the visibleOnly argument.
+2. Let areas be the result of finding focusable areas within the element with the visibleOnly.
3. Let anchors be a clone of areas,
with every focusable area which is not itself a Node replaced with its DOM anchor.
4. Return anchors
@@ -523,12 +524,13 @@ The {{Element/focusableAreas()}} method must follow these steps:
null,
- then let areas be that attribute.
+: spatialNavigationSearch(options)
+:: Follows these steps:
+1. Let direction be the value of {{SpatialNavigationSearchOptions/dir}} attribute from options.
+2. If the value of {{SpatialNavigationSearchOptions/candidates}} attribute from options is not null,
+ then let areas be the corresponding value.
3. Else, let container be
- * the argument's {{SpatialNavigationSearchOptions/container}} attribute, if it is not null,
+ * the value of {{SpatialNavigationSearchOptions/container}} attribute from options, if it is not null,
* the element's nearest spatial navigation container ancestor, otherwise.
4. Let areas be the result of finding focusable areas within container.
3. Return the result of selecting the best candidate within areas in direction direction from the element.
From 91ef58ad800aa95769a0f45954a1b0e92ace0965 Mon Sep 17 00:00:00 2001
From: Jihye Hong false
- if option is present and it's value is equal to 'all',
+ if option is present and its value is equal to 'all',
or true otherwise.
2. Let areas be the result of finding focusable areas within the element with the visibleOnly.
3. Let anchors be a clone of areas,
@@ -1294,7 +1294,7 @@ Note: In addition, as per [[#grouping]], the viewport of a browsing c
/* For browsers that don't support grid */
#example-cal table {
- display:inline-table
+ display:inline-table;
vertical-align: middle;
}
@@ -1456,7 +1456,7 @@ Answers are provided below.
'visible' is given to the {{FocusableAreasOptions/mode}} attribute of this method,
+ However, visible is given to the {{FocusableAreasOptions/mode}} attribute of this method,
the focusable element which isn’t inside the scrollport is excluded from the result.
@@ -1054,7 +1054,7 @@ run the following steps:
2. The User Agent should remove from focusables items that have a [=DOM anchor=] whose tabindex attribute is set to a negative value.
Note: This is a "SHOULD" in order to mirror the exclusion of elements with negative tabindex
- from the sequential focus navigation order as defined in [[HTML#the-tabindex-attribute]].
+ from the sequential focus navigation order as defined in [[HTML#attr-tabindex]].
3. If visibleOnly is false,
return focusables.
@@ -1078,7 +1078,7 @@ run the following steps:
authors should use make these elements unreachable to spatial navigation
using the same best practices as for making elements unreachable to sequential navigation,
such as using tab-index="-1"
- or the inert attribute.
+ or the inert attribute.