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: 多行文本二次渲染后少一行 #3089

Merged
merged 3 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions packages/s2-core/__tests__/bugs/issue-3087-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @description spec for issue #3087
lijinke666 marked this conversation as resolved.
Show resolved Hide resolved
* https://github.com/antvis/S2/issues/3087
*/
import { TableSheet } from '../../src';
import { getContainer } from '../util/helpers';

const data = Array(100).fill({
province: 'aaaa'.repeat(100),
city: 'aa',
});

describe('Table MaxLines Tests', () => {
test('should render maxLines text correctly after render twice', async () => {
const tableSheet = new TableSheet(
getContainer(),
{
fields: {
columns: ['province', 'city'],
},
meta: [
{
field: 'province',
name: '省份',
},
{
field: 'city',
name: '城市',
},
],
data,
},
{
width: 600,
height: 480,
style: {
colCell: {
maxLines: 3,
wordWrap: true,
textOverflow: 'ellipsis',
},
dataCell: {
maxLines: 3,
wordWrap: true,
textOverflow: 'ellipsis',
},
},
},
);

await tableSheet.render();
const actualText1 = tableSheet.facet.getDataCells()[0].getActualText();

await tableSheet.render();
const actualText2 = tableSheet.facet.getDataCells()[0].getActualText();

expect(actualText1).toEqual(actualText2);
});
});
2 changes: 1 addition & 1 deletion packages/s2-core/src/cell/base-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ export abstract class BaseCell<T extends SimpleBBox> extends Group {

const maxLines = Math.max(
1,
Math.floor((displayHeight - padding) / lineHeight),
Math.round((displayHeight - padding) / lineHeight),
Alexzjt marked this conversation as resolved.
Show resolved Hide resolved
Alexzjt marked this conversation as resolved.
Show resolved Hide resolved
);

return maxLines;
Expand Down
Loading