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(tooltip): 修复字段描述为英文时展示不全 #2466

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,28 @@ describe('StrategySheet Tooltip Tests', () => {
expect(screen.getAllByText('customDerivedValue')).toHaveLength(3);
expect(screen.getAllByText('customDerivedValue')).toMatchSnapshot();
});

// cli 的方式得到的结果是错, 基于 test:live 就是对的, 不知道为啥
test.skip('should render overflow wrap description for row tooltip', () => {
const description = `test_`.repeat(40);
const mockDescCellInfo = createMockCellInfo('test', {
extra: {
description,
},
});

const { container } = render(
<StrategySheetRowTooltip
cell={mockDescCellInfo.mockCell}
label="test row label"
/>,
);

const { width, height } = container!
.querySelector('.s2-strategy-sheet-tooltip-description-text')!
.getBoundingClientRect();

expect(Math.floor(width)).toBeCloseTo(937);
expect(Math.floor(height)).toBeCloseTo(37);
});
});
3 changes: 2 additions & 1 deletion packages/s2-react/__tests__/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function getMockSheetInstance(Sheet: typeof SpreadSheet = PivotSheet) {

export const createMockCellInfo = (
cellId: string,
{ colIndex = 0, rowIndex = 0 } = {},
{ colIndex = 0, rowIndex = 0, extra = {} } = {},
) => {
const mockCellViewMeta: Partial<ViewMeta> = {
id: cellId,
Expand All @@ -118,6 +118,7 @@ export const createMockCellInfo = (
getFieldName: jest.fn(),
},
} as unknown as SpreadSheet,
extra,
};
const mockCellMeta = omit(mockCellViewMeta, 'update');
const mockCell = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ export const StrategySheetDataTooltip: React.FC<CustomTooltipProps> = ({
)}
{rowDescription && (
<div className={tooltipCls('description')}>
{i18n('说明')}
{rowDescription}
<span className={tooltipCls('description-label')}>
{i18n('说明')}
</span>
<span className={tooltipCls('description-text')}>
{rowDescription}
</span>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export const StrategySheetRowTooltip: React.FC<CustomTooltipProps> = ({
<div className={tooltipCls('value')}>{rowName}</div>
{description && (
<div className={tooltipCls('description')}>
{i18n('说明')}
{description}
<span className={tooltipCls('description-label')}>
{i18n('说明')}
</span>
<span className={tooltipCls('description-text')}>{description}</span>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
margin: 10px -12px;
}

& &-description {
overflow-wrap: break-word;
}

// tooltip for row cell
// ------------------------------------------------------
&&-row &-value {
Expand Down
Loading