Skip to content

fix(target-size): determine offset using clientRects if target is display:inline#5012

Merged
straker merged 8 commits intodevelopfrom
target-offset-inline
Feb 20, 2026
Merged

fix(target-size): determine offset using clientRects if target is display:inline#5012
straker merged 8 commits intodevelopfrom
target-offset-inline

Conversation

@straker
Copy link
Copy Markdown
Contributor

@straker straker commented Feb 12, 2026

This pr does two things:

  1. For target size we decided to calculate the visible unobscured rects by taking the bounding rect of the target and subtracting the client rects of the obscurer if the obscurer is inline. This is because an inline element only accepts pointer events on the client rects and not the bounding rect. For the target we still take the bounding rect and not the client rects if the target is inline because we both agreed that the goal of the target size rule is to prevent clicking on the wrong target and not that the target itself is large enough to click on. So an inline element with multiple lines would have dead pointer zones within it, but accidentally clicking on a dead zone is not a failure of target size.
  2. This also applies using client rects for inline elements for the spacing exception for the same reasons as above. What this does is allow checking multiple target rects for inline nodes and makes sure each rect passes the spacing exception. If at least one rect does not pass the rule fails for that element.

Closes: #4928

@straker straker requested a review from a team as a code owner February 12, 2026 21:51
Comment on lines -16 to +18
const nodeRect = vNode.boundingClientRect;
const display = vNode.getComputedStylePropertyValue('display');
const nodeRects =
display === 'inline' ? vNode.clientRects : [vNode.boundingClientRect];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I THINK this should still use bounding rect... looking into it

const largestInnerRect = getLargestUnobscuredArea(
vNode,
obscuredWidgets,
minSize
Copy link
Copy Markdown
Contributor Author

@straker straker Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug were we didn't pass minSize into the largest rect calculation so no rect would pass min size check and it would default to picking the largest area rect.

// subtract the radius of the circle from the distance to center to get distance to edge of the neighbor circle
const centerDistance =
pointDistance(targetCenter, neighborCenter) - minRadiusNeighbour;
const neighborBoundingBox = neighborRects.reduce(getBoundingRect);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious. There are several const variables in this .reduce() loop. Does each pass through the loop alter these in any way? Might be a minor gain in performance but I was just curious if there was a way to move them out of the targetRects.reduce() loop.

chutchins25
chutchins25 previously approved these changes Feb 19, 2026
Copy link
Copy Markdown
Contributor

@chutchins25 chutchins25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. Just was curious about those const variables within a loop but that is not a show stopper to me.

? obscuredNode.clientRects
: obscuredNode.boundingClientRect;
})
.flat(Infinity);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? Why not just 2?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please pull this change. The rest looks right.

? overlappingVNode.clientRects
: overlappingVNode.boundingClientRect;
})
.flat(Infinity);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this is 2 layers deep. Why give it Infinity?

@straker straker merged commit a4b8091 into develop Feb 20, 2026
23 checks passed
@straker straker deleted the target-offset-inline branch February 20, 2026 17:15
WilcoFiers pushed a commit that referenced this pull request Mar 30, 2026
…play:inline (#5012)

This pr does two things:

1. For target size we decided to calculate the visible unobscured rects
by taking the bounding rect of the target and subtracting the client
rects of the obscurer if the obscurer is inline. This is because an
inline element only accepts pointer events on the client rects and not
the bounding rect. For the target we still take the bounding rect and
not the client rects if the target is inline because we both agreed that
the goal of the target size rule is to prevent clicking on the wrong
target and not that the target itself is large enough to click on. So an
inline element with multiple lines would have dead pointer zones within
it, but accidentally clicking on a dead zone is not a failure of target
size.
2. This also applies using client rects for inline elements for the
spacing exception for the same reasons as above. What this does is allow
checking multiple target rects for inline nodes and makes sure each rect
passes the spacing exception. If at least one rect does not pass the
rule fails for that element.

Closes: #4928
straker added a commit that referenced this pull request Mar 30, 2026
…play:inline (#5012)

This pr does two things:

1. For target size we decided to calculate the visible unobscured rects
by taking the bounding rect of the target and subtracting the client
rects of the obscurer if the obscurer is inline. This is because an
inline element only accepts pointer events on the client rects and not
the bounding rect. For the target we still take the bounding rect and
not the client rects if the target is inline because we both agreed that
the goal of the target size rule is to prevent clicking on the wrong
target and not that the target itself is large enough to click on. So an
inline element with multiple lines would have dead pointer zones within
it, but accidentally clicking on a dead zone is not a failure of target
size.
2. This also applies using client rects for inline elements for the
spacing exception for the same reasons as above. What this does is allow
checking multiple target rects for inline nodes and makes sure each rect
passes the spacing exception. If at least one rect does not pass the
rule fails for that element.

Closes: #4928
@straker straker mentioned this pull request Mar 30, 2026
WilcoFiers added a commit that referenced this pull request Mar 31, 2026
### [4.11.2](v4.11.1...v4.11.2)
(2026-03-30)

### Bug Fixes

- **aria-valid-attr-value:** handle multiple aria-errormessage IDs
([#4973](#4973))
([9322148](9322148))
- **aria:** prevent getOwnedVirtual from returning duplicate nodes
([#4987](#4987))
([99d1e77](99d1e77)),
closes [#4840](#4840)
- **DqElement:** avoid calling constructors with cloneNode
([#5013](#5013))
([88bc57f](88bc57f))
- **existing-rule:** aria-busy now shows an error message for a use with
unallowed children
([#5017](#5017))
([dded75a](dded75a))
- **scrollable-region-focusable:** clarify the issue is in safari
([#4995](#4995))
([2567afd](2567afd)),
closes
[WebKit#190870](https://github.com/dequelabs/WebKit/issues/190870)
[WebKit#277290](https://github.com/dequelabs/WebKit/issues/277290)
- **scrollable-region-focusable:** do not fail scroll areas when all
content is visible without scrolling
([#4993](#4993))
([240f8b5](240f8b5))
- **target-size:** determine offset using clientRects if target is
display:inline
([#5012](#5012))
([69d81c1](69d81c1))
- **target-size:** ignore widgets that are inline with other inline
elements ([#5000](#5000))
([cf8a3c0](cf8a3c0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Target-size issue with reflowing links

3 participants