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(interaction): 修复隐藏列头配置更新时未覆盖上一次的配置 close #2495 #2527

Merged
merged 5 commits into from
Jan 23, 2024

Conversation

lijinke666
Copy link
Member

@lijinke666 lijinke666 commented Jan 22, 2024

👀 PR includes

🐛 Bugfix

📝 Description

通过 interaction.hiddenColumnFields 配置动态改变隐藏列的场景中, 由于最终都是通过 s2.setOptions({ ... }) 的方式, 导致配置项会 merge, 而不是覆盖, 对于这种场景应该清除上一次记录的隐藏列信息.

if (!Object.is(prevOptions, options)) {
if (!Object.is(prevOptions?.hierarchyType, options?.hierarchyType)) {
// 自定义树目录需要重新构建 CustomTreePivotDataSet
reBuildDataSet = true;
reloadData = true;
s2Ref.current?.setDataCfg(dataCfg);
}
s2Ref.current?.setOptions(options as S2Options);

 const [hiddenColumnFields, setHiddenCols] = useState(["city", "price"]);

 const s2Options =  {
    width: 600,
    height: 480,
    interaction: {
      hiddenColumnFields: hiddenColumnFields,
    },
  };

  <button
    onClick={() => {
      setHiddenCols(['city']);
    }}
  >
    change city
  </button>
  <button
    onClick={() => {
      setHiddenCols(['type']);
    }}
  >
    change type
  </button>
  <button
    onClick={() => {
      setHiddenCols([]);
    }}
  >
    reset
  </button>

  <SheetComponent
    dataCfg={s2DataConfig}
    options={s2Options}
    sheetType="table"
  />

🖼️ Screenshot

Before After
Kapture 2024-01-22 at 11 34 00 Kapture 2024-01-22 at 11 31 44
Kapture 2024-01-22 at 15 50 16 Kapture 2024-01-22 at 15 48 40

🔗 Related issue link

closes #2507 #2495

🔍 Self-Check before the merge

  • Add or update relevant docs.
  • Add or update relevant demos.
  • Add or update test case.
  • Add or update relevant TypeScript definitions.

Copy link

vercel bot commented Jan 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
antvis-s2 ❌ Failed (Inspect) Jan 23, 2024 3:27am

Copy link
Contributor

github-actions bot commented Jan 22, 2024

Size Change: +63 B (0%)

Total Size: 441 kB

Filename Size Change
./packages/s2-core/dist/index.min.js 176 kB +54 B (0%)
./packages/s2-react/dist/index.min.js 68 kB +5 B (0%)
./packages/s2-vue/dist/index.min.js 20.5 kB +4 B (0%)
ℹ️ View Unchanged
Filename Size
./packages/s2-core/dist/style.min.css 389 B
./packages/s2-core/node_modules/@testing-library/dom/dist/@testing-library/dom.cjs.js 21.7 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/@testing-library/dom.esm.js 21.2 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.js 60.3 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/@testing-library/dom.umd.min.js 33.9 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/config.js 1.16 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/DOMElementFilter.js 1.87 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/event-map.js 1.18 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/events.js 1.55 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/get-node-text.js 300 B
./packages/s2-core/node_modules/@testing-library/dom/dist/get-queries-for-element.js 738 B
./packages/s2-core/node_modules/@testing-library/dom/dist/get-user-code-frame.js 810 B
./packages/s2-core/node_modules/@testing-library/dom/dist/helpers.js 1.07 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/index.js 1.14 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/label-helpers.js 1.05 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/matches.js 1.14 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/pretty-dom.js 1.47 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/all-utils.js 337 B
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/alt-text.js 573 B
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/display-value.js 713 B
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/index.js 418 B
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/label-text.js 1.8 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/placeholder-text.js 491 B
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/role.js 2.67 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/test-id.js 498 B
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/text.js 958 B
./packages/s2-core/node_modules/@testing-library/dom/dist/queries/title.js 718 B
./packages/s2-core/node_modules/@testing-library/dom/dist/query-helpers.js 1.81 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/role-helpers.js 2.82 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/screen.js 1.51 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/suggestions.js 1.5 kB
./packages/s2-core/node_modules/@testing-library/dom/dist/wait-for-element-to-be-removed.js 748 B
./packages/s2-core/node_modules/@testing-library/dom/dist/wait-for.js 2.38 kB
./packages/s2-react/dist/style.min.css 3.43 kB
./packages/s2-vue/dist/style.min.css 1.68 kB

compressed-size-action

Copy link

codecov bot commented Jan 22, 2024

Codecov Report

Attention: 176 lines in your changes are missing coverage. Please review.

Comparison is base (1adc25d) 76.48% compared to head (9733ac0) 76.79%.
Report is 125 commits behind head on master.

❗ Current head 9733ac0 differs from pull request most recent head fe508e1. Consider uploading reports for the commit fe508e1 to get more accurate results

Files Patch % Lines
packages/s2-core/src/cell/base-row-cell.ts 71.72% 22 Missing and 19 partials ⚠️
packages/s2-core/src/facet/frozen-facet.ts 82.01% 2 Missing and 32 partials ⚠️
packages/s2-core/src/facet/pivot-facet.ts 79.12% 4 Missing and 15 partials ⚠️
packages/s2-core/src/data-set/pivot-data-set.ts 80.32% 1 Missing and 11 partials ⚠️
...ckages/s2-core/src/facet/header/base-frozen-row.ts 85.36% 0 Missing and 6 partials ⚠️
...s/s2-core/src/facet/layout/build-gird-hierarchy.ts 82.35% 1 Missing and 5 partials ⚠️
...eraction/base-interaction/click/data-cell-click.ts 50.00% 3 Missing and 3 partials ⚠️
packages/s2-core/src/data-set/table-data-set.ts 66.66% 0 Missing and 5 partials ⚠️
packages/s2-core/src/facet/header/row.ts 58.33% 5 Missing ⚠️
packages/s2-core/src/facet/layout/layout-hooks.ts 0.00% 3 Missing and 1 partial ⚠️
... and 23 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2527      +/-   ##
==========================================
+ Coverage   76.48%   76.79%   +0.31%     
==========================================
  Files         240      249       +9     
  Lines       12312    12767     +455     
  Branches     2630     2750     +120     
==========================================
+ Hits         9417     9805     +388     
+ Misses       1377     1365      -12     
- Partials     1518     1597      +79     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lijinke666
Copy link
Member Author

ref #2511

@lijinke666 lijinke666 merged commit d68adcc into master Jan 23, 2024
10 of 11 checks passed
@lijinke666 lijinke666 deleted the fix-2495 branch January 23, 2024 06:49
lijinke666 added a commit that referenced this pull request Jan 24, 2024
* fix(interaction): 修复隐藏列头配置更新时未覆盖上一次的配置 close #2495

* test: 更新单测描述

* fix: 提取函数

* docs: 更新隐藏列头相关 demo
@lijinke666
Copy link
Member Author

🎉 This PR is included in version @antv/s2-v1.54.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member Author

🎉 This PR is included in version @antv/s2-react-v1.46.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lijinke666
Copy link
Member Author

🎉 This PR is included in version @antv/s2-vue-v1.6.1 🎉

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
Projects
None yet
2 participants