You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, there is little feedback to the user regarding the current content being viewed, and
886
891
the interaction model does not match the expectations of modern accessible UI components.
887
892
888
-
This specification adds a mechanism for creating scroll navigation controls.
889
-
The active marker, reflecting the current position, can be styled to give the user an indication of which section they are in.
890
-
The set of markers are treated as a component following the accessibility guidelines for keyboard navigation within components.
893
+
This specification adds a mechanism for creating scroll navigation controls within groups of <{a}> elements.
894
+
A group is created through the focusgroup attribute
895
+
on an ancestor containing one or more <{a}> elements whose indicated part is on the current page.
896
+
Within each group, the active marker reflects the current scroll position, and can be styled to give the user an indication of which section they are in.
891
897
892
898
Use cases include a table of contents with links to relevant contents,
893
899
markers for scrolling carousel pages,
894
900
and scrollable tab panels.
895
901
896
902
Issue: Add images representing these examples.
897
903
898
-
Issue: Explore whether scrolltarget can be more directly associated with anchor tags.
899
-
900
-
<{button/scrolltarget}> attribute
901
-
902
-
The scrolltarget attribute turns a <{button}> element into a [=scroll marker control=].
903
-
This takes the ID of the element to target as its value.
904
-
905
-
The HTMLButtonElement.scrollTargetElement instance property
906
-
gets and sets the element being interacted with by the control button.
907
-
This is the JavaScript equivalent of the <{button/scrolltarget}> HTML attribute.
904
+
{{HTMLLinkElement/scrollTargetElement}} attribute
908
905
909
-
A 'button' with a non-null {{HTMLButtonElement/scrollTargetElement}}
910
-
represents a scroll marker control that forms a scroll marker group for its nearest [=scroll container=]
911
-
in which exactly one control in the group can have its 'checked' state set to true.
912
-
A [=scroll marker control=] with a true 'checked' state can be styled by the '':checked'' pseudo-class.
906
+
An <{a}> element has its {{HTMLLinkElement/scrollTargetElement}}
907
+
initialized to the result of running the select the indicated part given the current {{Document}} and the href attribute value as the |URL|,
908
+
turning it into a [=scroll marker control=] if the resulting indicated part is non-null.
913
909
914
-
The [=scroll marker group=] that contains a <{button}> element a also contains all the other <{button}> elements b that fulfill the following conditions:
910
+
The HTMLLinkElement.scrollTargetElement instance property
911
+
gets and sets the element being interacted with by the anchor link and can be used to override the initial value established by the |href| property.
915
912
916
-
* The <{button}> element b has a non-null {{HTMLButtonElement/scrollTargetElement}} value.
917
-
* a and b's {{HTMLButtonElement/scrollTargetElement}} have the same nearest [=scroll container=].
913
+
An <{a}> element or ''::scroll-marker'' pseudo-element with a non-null {{HTMLLinkElement/scrollTargetElement}}
914
+
represents a scroll marker control which participates in a scroll marker group
915
+
defined by the containing ''::scroll-marker-group'' psuedo-element (for ''::scroll-marker'' pseudo-elements)
916
+
or nearest ancestor element establishing a focusgroup.
917
+
Exactly one control in a group will have its "checked" state set to true.
918
+
A [=scroll marker control=] with a true "checked" state can be styled by the '':checked'' pseudo-class.
918
919
919
920
920
-
When a [=scroll marker control=] is activated:
921
+
When a [=scroll marker control=] is activated by explicit invocation or arrow key focus:
921
922
922
-
1. Let element be the {{HTMLButtonElement/scrollTargetElement}} of the control.
923
+
1. Let element be the {{HTMLLinkElement/scrollTargetElement}} of the control.
1. If activated by invocation, move focus to element.
927
-
If element is not focusable this will result in there being no active element,
928
-
but the next focus change will proceed from this element as if it were focused.
929
-
927
+
1. : If the activation was triggered by invocation
928
+
::
929
+
1. Follow the hyperlink updating the URL, however retain focus on the marker element.
930
930
931
-
Issue: Moving focus to the control on activation means that the only way to control scroll markers via the keyboard is to tab into them.
932
-
We should retain focus after the control is activated, while still altering the point from which the next focusable element is found if the user tabs away.
931
+
Note: If the user tabs away the focus behavior will ensure they tab into the relevant content.
932
+
933
933
934
934
Scroll tracking
935
935
@@ -938,47 +938,45 @@ Issue: Explore whether scrolltarget can be more directly associated with anchor
938
938
or might directly track a user’s input
939
939
(e.g. touch scrolling, scrollbar dragging).
940
940
In either case, the user agent chooses an 'eventual scroll position' to which the scroller
941
-
will reach.
941
+
will reach. This ensures that the relevant marker is activated immediately.
942
942
943
-
This 'eventual scroll position' is used to determine the active marker.
943
+
This 'eventual scroll position' is used to determine the active marker within each [=scroll marker group=].
944
944
Since markers themselves may represent just the start of the content (e.g. headers), we consider the active marker to be the first one which we are at or beyond the scroll position of.
945
945
946
946
947
947
Whenever a [=scroll container=] is scrolled, or layout changes the scroll position, the user agent must run these steps to determine the active marker:
948
948
949
949
1. Let position be the 'eventual scroll position' for the scrolling operation.
950
-
1. Let markers be all of the [=scroll marker control=] elements which are a part of the [=scroll marker group=] for the [=scroll container=].
951
-
1. Let targets be the set of {{HTMLButtonElement/scrollTargetElement}} for those controls sorted in [=tree order=].
952
-
1. Let selected be the first element in targets, or null if targets is empty.
953
-
1. For each target in targets:
954
-
1. Set selected to target.
955
-
1. Let targetPosition be the position that would be scrolled to if we scroll target into view.
956
-
1. : If targetPosition's scroll block offset is less than or equal to position's scroll block offset, and
957
-
targetPosition's scroll inline offset is less than or equal to position's scroll inline offset.
958
-
::
959
-
Update selected to target.
960
-
Break.
961
-
1. : If selected is not null,
962
-
::
963
-
1. Let marker be the first control in markers whose {{HTMLButtonElement/scrollTargetElement}} is selected.
964
-
1. Set the 'checked' state of marker to true.
965
-
: Otherwise,
966
-
::
967
-
Set the 'checked' state of all controls in markers to false.
968
-
950
+
1. For each focusgroup group containing one or more [=scroll marker control=] elements whose {{HTMLLinkElement/scrollTargetElement}} is a descendant of [=scroll container=]:
969
951
970
-
Issue: Should we allow for none of the markers to be currently active, e.g. if not yet scrolled past the position of the first marker.
952
+
1. Let markers be all of the [=scroll marker control=] elements which are a part of the [=scroll marker group=] for the [=scroll container=].
953
+
1. Let targets be the {{HTMLLinkElement/scrollTargetElement}}s of |markers|, associated with the item of |markers| they came from, and sorted in [=tree order=].
1. Let |selected target| be the largest-indexed item of |targets|
956
+
whose associated |target position| is equal to or before |position| in both the block and inline axises in the current writing mode direction of the [=scroll container=].
971
957
972
-
Focus behavior
958
+
Issue: When the next marker is closer to being aligned than the previous we should use the next marker, in a manner similar to mandatory snap point selection.
973
959
974
-
A [=scroll marker control=] is only focusable if it is 'checked'. Within a group, exactly one marker is 'checked' at a time.
960
+
1. : If there is no such item,
961
+
::
962
+
Set the "checked" state of all |markers| in the |group| to false and return.
963
+
964
+
1. Let |selected marker| be the marker associated with |selected target|.
965
+
If multiple items of |markers| are associated with |selected target|,
966
+
set |selected marker| to be the marker that is earliest in tree order.
967
+
1. Set the "checked" state of |selected marker| to true.
0 commit comments