Skip to content
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

fix: mark position calculation when only x or y are defined #974

Merged
merged 2 commits into from
Nov 16, 2024

Conversation

marshallpete
Copy link
Contributor

Mark Position Bug Fix

It's possible for only x or y to be defined on a group item. The logic in place checked if both were defined and then summed their offsets. This fix checks them independently so that if only one or the other is defined, they are still summed up.

Verification

Validated against @adobe/react-spectrum-charts that this change fixes the bug I was seeing there.

A test has been added to verify and catch this.

src/position.ts Outdated
Comment on lines 99 to 104
if ('x' in parentItem) {
left += parentItem.x;
}
if ('y' in parentItem) {
top += parentItem.y;
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a simpler version could be something like left += parentItem.x ?? 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done ✅

@domoritz domoritz merged commit 795bd70 into vega:main Nov 16, 2024
4 checks passed
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.

2 participants