Skip to content

fix(target-size): correctly calculate bounding box#4125

Merged
straker merged 8 commits intodevelopfrom
target-offset-algorithm
Aug 21, 2023
Merged

fix(target-size): correctly calculate bounding box#4125
straker merged 8 commits intodevelopfrom
target-offset-algorithm

Conversation

@straker
Copy link
Copy Markdown
Contributor

@straker straker commented Aug 9, 2023

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

@straker straker requested a review from a team as a code owner August 9, 2023 20:18
dbjorge
dbjorge previously requested changes Aug 9, 2023
Copy link
Copy Markdown
Contributor

@dbjorge dbjorge left a comment

Choose a reason for hiding this comment

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

Thanks @straker ! Some notes inline

* @return {DOMRect[]}
*/
function getTargetRects(vNode) {
const nodeRect = 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 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.

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.

#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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this as part of #4120

*/
function getTargetRects(vNode) {
const nodeRect = vNode.boundingClientRect;
const overlappingVNodes = findNearbyElms(vNode).filter(vNeighbor => {
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 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this as part of #4120

dbjorge
dbjorge previously approved these changes Aug 9, 2023
Copy link
Copy Markdown
Contributor

@dbjorge dbjorge left a comment

Choose a reason for hiding this comment

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

LGTM modulo the work deferred for #4120, but would be good to have @WilcoFiers 's eyes on it too

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.

Update math.getOffset algorithm to better align with spec

3 participants