-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add target size enhanced rule #1919
Draft
WilcoFiers
wants to merge
46
commits into
develop
Choose a base branch
from
target-size-enhanced
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 40 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
1f3a63a
Add target size enhanced rule
WilcoFiers cfef38b
Rework a bit normative parts
Jym77 9a82752
Merge branch 'develop' into target-size-enhanced
Jym77 9ceba73
Merge branch 'develop' into target-size-enhanced
Jym77 c48767d
Refine rule a bit
Jym77 218bd99
Polish draft a bit
Jym77 62d2c9d
more work
Jym77 fa487ad
Merge branch 'develop' into target-size-enhanced
Jym77 90c4107
Attempt to write barebone defs
Jym77 67184e0
Some more notes
Jym77 b081edd
Text spacing rewrite (#1923)
Jym77 3f188b2
"Meta viewport allows for zoom" (b4f0c3): Explicit meaning of 'has' (…
Jym77 39748a1
Map Empty-heading rule to ARIA instead of WCAG (#2120)
WilcoFiers 58463aa
Deprecate 4.1.1 rules (#2117)
WilcoFiers 01a9d63
Fix markup issue in Iframe has name rule (#2116)
WilcoFiers dad2491
Stop linking to proposed rules (#2108)
WilcoFiers bb06ca3
Fix image-button accessibility support editorial oversight (#2106)
WilcoFiers a87ffeb
"Iframe not with interactive element" [akn7bn]: handle inert iframe (…
Jym77 1ea2503
Add much more examples
Jym77 23dc14b
Add much more examples
Jym77 c79f2f5
Merge branch 'develop' into target-size-enhanced
Jym77 e415158
Add more examples
Jym77 56bfa49
Merge branch 'develop' into target-size-enhanced
Jym77 4dffd15
Revert definition of clickable area
Jym77 38046c7
Clean up
Jym77 21f7cca
Merge branch 'develop' into target-size-enhanced
Jym77 5c492fb
Improve definition
Jym77 13e6ab8
Do not use aria-labelledby on raw div
Jym77 a37d2d9
Add definitions of implicit and explicit labels
Jym77 1351979
Add definition of shape-shifted element
Jym77 089d7aa
Clean up
Jym77 f5eb6d0
Remove example numbering until solidification
Jym77 f05a6ae
Merge branch 'develop' into target-size-enhanced
Jym77 3bf353f
Revert unrelated typo fix
Jym77 6618579
Write definitions
Jym77 421c5bf
Typos
Jym77 af064f2
Revert unrelated typo fix
Jym77 b4fe1de
Remove unrelated typo fix
Jym77 b65434a
Merge branch 'develop' into target-size-enhanced
Jym77 5faa824
Merge branch 'develop' into target-size-enhanced
7dc621c
Merge branch 'develop' into target-size-enhanced
Jym77 f92d3bb
Update rule and definition
Jym77 37a794a
Merge branch 'develop' into target-size-enhanced
Jym77 301f1f4
Clean up examples
Jym77 8719b7a
Move UA controlled exception from Applicability to Expectation
Jym77 cb8149c
Typo in link
Jym77 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
title: Can be target by a pointer event | ||
key: can-be-targeted-by-pointer-event | ||
unambiguous: true | ||
objective: true | ||
input_aspects: | ||
- CSS styling | ||
- DOM tree | ||
--- | ||
|
||
An element _can be targeted by pointer events_ when all the following conditions are true: | ||
|
||
- the element is a [semantic `widget`][semantic role]; and | ||
- the element is [focusable][]; and | ||
- the element's [border box][] intersects the viewport; and | ||
- the element's [border box][] is not entirely covered by the [border boxes][] of elements with greater `z-index` and `pointer-events: auto` CSS properties. | ||
|
||
#### Background | ||
|
||
This definition tries to capture which HTML elements can actually react to pointer events. It is not possible to have an exact definition of these for two main reasons: | ||
|
||
- Sometimes, the element that handles the event is not the element that appear to react to it, but an ancestor (or descendant) capturing the event during propagation or bubbling. In the most extreme case, the `body` element of a page could be the only one with an event handler, acting differently depending on where the event actually occurred. In such a case, a button would be perceived by users as something that can be targeted by a pointer event, while technically it is the `body` element which is targeted. | ||
- It is not possible to query the list of event listeners on a given elements. Some User Agents offer way to monitor events fired at a given element, but none offer a way to query for event listeners. Additionally, an event listener might ultimately do nothing and thus, for users, the corresponding element wouldn't look like it can be targeted by pointer events (since it effectively wouldn't react to them). | ||
|
||
As a consequence, this definition has these two known limitations: | ||
|
||
- Not all HTML elements that can actually be targeted by a pointer event match this definition. For example, an author may build custom buttons without giving them an appropriate role or making them [focusable][]; or content overflowing the [border box][] is clickable. Elements that can actually be targeted by pointer events but do not match this definition likely fail either [Success Criterion 4.1.2 Name, Role, Value][sc412] or [Success Criterion 2.1.1 Keyboard][sc211]. | ||
- Not all HTML elements that match this definition can actually be targeted by a pointer event. For example, when the actual clickable area does not cover the full [border box][] and is entirely covered by other elements, or when the element has an event handler that does nothing. Elements that match this definition but cannot actually be targeted by pointer events likely fail [Success Criterion 2.5.6 Concurrent Input Mechanisms][sc256]. | ||
|
||
[border box]: https://www.w3.org/TR/css-box-3/#border-box 'CSS definition of Border Box' | ||
[clickable area]: #clickable-area 'Definition of Clickable Area' | ||
[focusable]: #focusable 'Definition of Focusable' | ||
[sc211]: https://www.w3.org/TR/WCAG22/#keyboard 'Success Criterion 2.1.1 Keyboard' | ||
[sc256]: https://www.w3.org/TR/WCAG22/#concurrent-input-mechanisms 'Success Criterion 2.5.6 Concurrent Input Mechanisms' | ||
[sc412]: https://www.w3.org/TR/WCAG22/#name-role-value 'Success Criterion 4.1.2 Name, Role, Value' | ||
[semantic role]: #semantic-role 'Definition of Semantic Role' | ||
[visible]: #visible ' Definition of Visible' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
title: Clickable area | ||
key: clickable-area | ||
unambiguous: true | ||
objective: false | ||
input_aspects: | ||
- CSS styling | ||
- DOM tree | ||
--- | ||
|
||
The _directly clickable area_ of an element is the set of all viewport coordinates for which the element is the [topmost event target][] | ||
|
||
The _clickable area_ of an element is the union of its _directly clickable area_ and that of its [implicit][implicit label] or [explicit label][]. | ||
|
||
[explicit label]: #programmatic-label:explicit 'Definition of Explicit Label' | ||
[implicit label]: #programmatic-label:implicit 'Definition of Implicit Label' | ||
[topmost event target]: https://w3c.github.io/uievents/#topmost-event-target 'CSS definition of Topmost Event Target' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: Shape-Shifted Element | ||
key: shape-shifted-element | ||
unambiguous: true | ||
objective: true | ||
input_aspects: | ||
- CSS styling | ||
- DOM tree | ||
--- | ||
|
||
An element is _shape-shifted_ if it has an [inclusive ancestor][] in the [flat tree][] with any of its [shape-shifting properties][] whose [computed value][] is different from the [initial value][] of that property. | ||
|
||
> comment: shape-shifting an ancestor can shape-shifting the element, e.g. with `transform` or clipping. OTOH, this might be very trigger happy in considering everything inside a modal shape shifted just because the modal has rounded corners… | ||
|
||
The <dfn id="shape-shifted-element:properties">Shape-Shifting Properties</dfn> are the following CSS properties: | ||
|
||
- `border-radius` and the associated longhands; | ||
- `transform`; | ||
- `rotate`; | ||
- `clip`; | ||
- `clip-path`; | ||
|
||
#### Background | ||
|
||
Shape-shifted elements have an actual area on screen that can be very different from a rectangle aligned with the screen edges, and therefore hard to precisely compute. Rules looking at this area ignore shape-shifted elements for the sake of simplicity. | ||
|
||
Not all shape-shifting properties significantly change the shape of an element. For example, a rotation of 180°, a `transform` property defining only the `translate` function, or a `clip-path` along a rectangular shape would not really alter the shape. This definition ignores these for the sake of simplicity. | ||
|
||
Other CSS properties may alter the area covered by an element, for examples `height` or `width`. These properties, however, do not alter the _shape_ (rectangle aligned with the edges) and tend to keep the covered area and the CSS box model in harmony. Therefore, this definition doesn't include them. | ||
|
||
[inclusive ancestor]: https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor 'DOM Definition of Inclusive Ancestor' | ||
[computed value]: https://www.w3.org/TR/css-cascade-5/#computed-value 'CSS definition of computed value' | ||
[flat tree]: https://drafts.csswg.org/css-scoping/#flat-tree 'CSS Definition of flat tree' | ||
[initial value]: https://www.w3.org/TR/css-cascade-5/#initial-value 'CSS definition of initial value' | ||
[shape-shifting properties]: #shape-shifted-element:properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: User-Agent Controlled Component | ||
key: user-agent-controlled-component | ||
unambiguous: true | ||
objective: true | ||
input_aspects: | ||
- CSS styling | ||
- DOM tree | ||
--- | ||
|
||
A _User-Agent Controlled Component_ is an [HTML element][namespace element] for which all the following are true: | ||
|
||
- the element has an [implicit role][] which is a [semantic `widget`][semantic role]; and | ||
- none of the following CSS properties of the element have a [cascaded value][] with "Author" [origin][]: `height`, `width`, `font-size`, `line-height`. | ||
|
||
[cascaded value]: https://www.w3.org/TR/css-cascade-5/#cascade-value 'CSS definition of computed value' | ||
[implicit role]: #implicit-role 'Definition of Implicit Role' | ||
[origin]: https://drafts.csswg.org/css-cascade-5/#cascading-origins 'CSS definition of Cascading Origin' | ||
[namespaced element]: #namespaced-element 'Definition of Namespaced Element' | ||
[semantic role]: #semantic-role 'Definition of Semantic Role' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Create an element with class "highlight" around a node. | ||
* The node needs to be non-static to allow for z-index lower than | ||
* the highlighted element, otherwise the .highlight element will prevent | ||
* click events to reach the node. | ||
* | ||
* An optional set of classes can also be added to the highlighted element, | ||
* these are mostly intended to be either ['good'] (default) or ['bad'] to set | ||
* the color and style of the highlighting border. | ||
*/ | ||
function highlightRect(node, classes = ['good']) { | ||
// Get the bounding client rect of the node | ||
const range = document.createRange() | ||
range.setStart(node, 0) | ||
// Take the length of text nodes, if it exists, otherwise (element), take | ||
// all child nodes | ||
range.setEnd(node, node?.length ?? node.childNodes.length) | ||
const rect = range.getBoundingClientRect() | ||
|
||
// Create a div sized to that rect | ||
// See https://developer.mozilla.org/en-US/docs/Web/API/Element/getClientRects#javascript | ||
const div = document.createElement('div') | ||
div.classList.add('highlight', ...classes) | ||
div.style.top = `${rect.top}px` | ||
div.style.left = `${rect.left}px` | ||
div.style.width = `${rect.width - 2}px` | ||
div.style.height = `${rect.height - 2}px` | ||
document.body.appendChild(div) | ||
|
||
return div | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.highlight { | ||
position: absolute; | ||
z-index: 0; | ||
} | ||
|
||
.good { | ||
border: green solid 1px; | ||
} | ||
.bad { | ||
border: red dashed 1px; | ||
} | ||
|
||
.highlightable { | ||
position: relative; | ||
z-index: 5; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to consider also open dialogs?
https://html.spec.whatwg.org/multipage/interactive-elements.html#attr-dialog-open
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure exactly what you mean 🤔
Is it about elements "behind" the modal being blocked by it when it's opened (even if they are visible)?
I think that this is covered because in that case, their "clickable area" would be empty (the blocked elements are never topmost target, until the modal is closed and stops blocking them).