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

🐛 交叉表 compact 模式下,列头宽计算有误 #969

Closed
lcx-seima opened this issue Jan 6, 2022 · 2 comments · Fixed by #972
Closed

🐛 交叉表 compact 模式下,列头宽计算有误 #969

lcx-seima opened this issue Jan 6, 2022 · 2 comments · Fixed by #972
Assignees
Labels
🐛 bug 这个是一个 bug released

Comments

@lcx-seima
Copy link
Contributor

lcx-seima commented Jan 6, 2022

🏷 Version

Package Version
@antv/s2 1.4.0
@antv/s2-react 1.4.0

🖋 Description

compact 模式下计算列头宽,错误地使用了 field 格式化前的原始 id

⌨️ Code Snapshots

import React from 'react';
import ReactDOM from 'react-dom';
import { SheetComponent } from '@antv/s2-react';
import '@antv/s2-react/dist/style.min.css';

fetch(
  'https://gw.alipayobjects.com/os/bmw-prod/2a5dbbc8-d0a7-4d02-b7c9-34f6ca63cff6.json',
)
  .then((res) => res.json())
  .then((dataCfg) => {
    // original: fields.values = ['number']
    //           data = [{ ..., number: 123, ... }]
    //           meta = [{ field: 'number', name: '数量' }]

    const newValueKey = 'a-long-field-id-that-trigger-width-calc-bug';
    dataCfg.fields.values[0] = newValueKey;
    dataCfg.meta[0].field = newValueKey;
    dataCfg.data.forEach(item => item[newValueKey] = item.number);

    const s2Options = {
      width: 600.32,
      height: 480,
      style: {
        layoutWidthType: 'compact',
        frozenRowHeader: true,
        colCfg: {
          height: 32,
        },
        device: 'pc'
      }
    };

    ReactDOM.render(
      <SheetComponent dataCfg={dataCfg} options={s2Options} />,
      document.getElementById('container'),
    );
  });

🔗 Reproduce Link

🤔 Steps to Reproduce

😊 Expected Behavior

😅 Current Behavior

CleanShot 2022-01-07 at 14 19 56@2x

💻 System information

@lcx-seima lcx-seima added the 🐛 bug 这个是一个 bug label Jan 6, 2022
@lcx-seima lcx-seima self-assigned this Jan 6, 2022
@lcx-seima
Copy link
Contributor Author

lcx-seima commented Jan 6, 2022

补充其他情况

  • 上述复现 code + valueInCols: false 情况
  • 其他 meta 有 formatter 情况:formatter: val => "超级长的格式化" + val

@lijinke666
Copy link
Member

🎉 This issue has been resolved in version @antv/s2-v1.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug 这个是一个 bug released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants