-
Notifications
You must be signed in to change notification settings - Fork 44
Handle board-relative anchor offsets #447
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
Handle board-relative anchor offsets #447
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Size ReportBundle Size
Install Size
Full Howfat Output (PR Branch) |
Size ReportBundle Size
Install Size
Full Howfat Output (PR Branch) |
| const baseValue = displayOffset ?? offsetMm.toFixed(2) | ||
| const valueStr = | ||
| typeof baseValue === "number" ? baseValue.toString() : baseValue | ||
| const hasUnit = typeof valueStr === "string" && valueStr.trim().endsWith("mm") | ||
| const unitSuffix = hasUnit ? "" : "mm" | ||
|
|
||
| return `${axis}: ${valueStr}${unitSuffix}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function doesn't handle empty string displayOffset properly. If displayOffset is an empty string "", the nullish coalescing operator (??) will use it instead of falling back to the calculated value, resulting in labels like "X: mm" or "Y: mm".
Fix:
function formatOffsetLabel(
axis: "X" | "Y",
offsetMm: number,
displayOffset?: number | string,
): string {
const baseValue = displayOffset ?? offsetMm.toFixed(2)
const valueStr =
typeof baseValue === "number" ? baseValue.toString() : baseValue
// Handle empty strings
if (typeof valueStr === "string" && valueStr.trim() === "") {
return `${axis}: ${offsetMm.toFixed(2)}mm`
}
const hasUnit = valueStr.trim().endsWith("mm")
const unitSuffix = hasUnit ? "" : "mm"
return `${axis}: ${valueStr}${unitSuffix}`
}| const baseValue = displayOffset ?? offsetMm.toFixed(2) | |
| const valueStr = | |
| typeof baseValue === "number" ? baseValue.toString() : baseValue | |
| const hasUnit = typeof valueStr === "string" && valueStr.trim().endsWith("mm") | |
| const unitSuffix = hasUnit ? "" : "mm" | |
| return `${axis}: ${valueStr}${unitSuffix}` | |
| const baseValue = displayOffset ?? offsetMm.toFixed(2) | |
| const valueStr = | |
| typeof baseValue === "number" ? baseValue.toString() : baseValue | |
| // Handle empty strings | |
| if (typeof valueStr === "string" && valueStr.trim() === "") { | |
| return `${axis}: ${offsetMm.toFixed(2)}mm` | |
| } | |
| const hasUnit = typeof valueStr === "string" && valueStr.trim().endsWith("mm") | |
| const unitSuffix = hasUnit ? "" : "mm" | |
| return `${axis}: ${valueStr}${unitSuffix}` |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
1 similar comment
|
Thank you for your contribution! 🎉 PR Rating: ⭐⭐⭐ Track your contributions and see the leaderboard at: tscircuit Contribution Tracker |
Summary
Testing
Codex Task