w3c / wcag

Web Content Accessibility Guidelines
https://w3c.github.io/wcag/guidelines/22/
Other
1.11k stars 251 forks source link

Target spacing (minimum): multiple overlapping elements interact oddly with offset #2159

Closed WilcoFiers closed 2 years ago

WilcoFiers commented 2 years ago

In working on automated tests, I ran into something I hadn't realised before. When an element is overlapped by multiple other elements, it is possible to pass the SC with a very small target on the outer element. In particular scenario H4 from my codepen:

https://codepen.io/wilcofiers/pen/abZxPow?editors=1100 Screenshot 2021-12-07 at 14 21 57

H4 shows a rectangle with two squares on top of it. The squares touching edges horizontally. The squares have a 24x24 diameter and so pass. The rectangle is only visible as a 6 pixel wide perimeter around the two squares.

The reason this passes is because to the offset from the rectangle to either square is a diagonal from their top-right corners for the left square, or their top-left corners for the right square. For both squares the offset is slightly more than 30 pixels, so the rectangle meets the offset exception. The odd thing here is if those two squares were treated as a single target, the SC would fail. But because there are two of them, the SC passes.

I have no suggestion on how to fix this, without causing a good deal of other problems that might get overlooked. Given how unusual this case is, I think it's acceptable to ignore it. But I did want to point it out so we're conscious of it.

alastc commented 2 years ago

Accepted response:


From the discussion, it appears that updating the normative text to prevent edge-cases of nested links using diagonals will over-complicate the SC. Therefore the group decided not to create such an update.

On the issues of accounting for nested items contributing to spacing, PR #2330 has been created to address that.

The PR was updated to remove the "Targets other than A and B…", but keep the other minor changes.

veselints commented 1 year ago

Sorry, for rising the topic again, but can you slightly change the exception description text, so that it requires the offset must be calculated from the same point in a target to all other targets. Just to force the following calculation as it has been discussed above:

Rec

The following text:

Target offset is the length of the longest possible line that starts at an edge of a target (A), intersects a second edge of A, and ends at the closest edge of a second target (B). It is assessed from a target to each other nearby target; the target offset must be at least 24 CSS pixels to all nearby targets to fall under this exception.

could be altered to:

Target offset is the length of the longest possible line that starts at an edge of a target (A), intersects a second edge of A, and ends at the closest edge of a second target (B). It is assessed from a point on an edge of the target to each other nearby targets; the target offset must be at least 24 CSS pixels to all nearby targets to fall under this exception.