fix(target-size): correctly calculate bounding box#4125
Conversation
| * @return {DOMRect[]} | ||
| */ | ||
| function getTargetRects(vNode) { | ||
| const nodeRect = vNode.boundingClientRect; |
There was a problem hiding this comment.
I think this will eventually need to be more complicated in order to address the issue @WilcoFiers pointed out the other day where boundingClientRect doesn't take into account cases where a target has a descendant element that's part of the target for the purposes of the SC, but which overflow the bounding box of the target (eg, a link with an inline image that exceeds the link's line height).
I think it's okay for this PR to not address that, but it'd be good to file a new tech debt item to track it and add a breadcrumb to the issue here.
There was a problem hiding this comment.
#3673 is closely related, but the fix that closed it only covered the target-size check, I think the target-offset check is still vulnerable to the same issue
| */ | ||
| function getTargetRects(vNode) { | ||
| const nodeRect = vNode.boundingClientRect; | ||
| const overlappingVNodes = findNearbyElms(vNode).filter(vNeighbor => { |
There was a problem hiding this comment.
I know this is just moved and not written in this PR, but I'm noticing as I'm looking at it that it's probably incorrectly considering non-separate-target-descendants as obscuring the target rather than being part of the target. I think this needs to be more complex, along the same lines as filterByElmsOverlap in target-size-evaluate
dbjorge
left a comment
There was a problem hiding this comment.
LGTM modulo the work deferred for #4120, but would be good to have @WilcoFiers 's eyes on it too
The integration tests had to be updated with this change. The passing examples were failing as the target circle was indeed overlapping the other target (just barely). I updated them with a larger distance so they would still pass for the first 2 cases.
Closes: #4119