Skip to content

Commit

Permalink
fix: fix textAlign value in width update#1065
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Feb 5, 2024
1 parent b9cdd52 commit 11d7320
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: fix textAlign value in width update#1065",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
6 changes: 3 additions & 3 deletions packages/vtable/src/scenegraph/utils/text-icon-layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,13 @@ export function updateCellContentWidth(
} else if (child.role === 'icon-absolute-right') {
child.setAttribute('x', child.attribute.x + detaX);
} else if (child.name === 'content' || child.name === 'text') {
const contentWidth = child.AABBBounds.width();
if (textAlign === 'center') {
const childTextAlign = child.attribute.textAlign ?? textAlign;
if (childTextAlign === 'center') {
child.setAttribute(
'x',
padding[3] + leftIconWidth + (distWidth - (padding[1] + padding[3]) - leftIconWidth - rightIconWidth) / 2
);
} else if (textAlign === 'right') {
} else if (childTextAlign === 'right') {
child.setAttribute('x', padding[3] + distWidth - (padding[1] + padding[3]) - rightIconWidth);
} else {
// left: do nothing
Expand Down

0 comments on commit 11d7320

Please sign in to comment.