G6 icon indicating copy to clipboard operation
G6 copied to clipboard

fixCollapseSize is not respected when combo type is circle

Open bsansone opened this issue 1 year ago • 2 comments

Describe the bug

When you create a combo with type circle the property fixCollapseSize is not respected. If you change the type of the combo to rect you can see the property fixCollapseSize working.

Your Example Website or App

https://codesandbox.io/s/awesome-mahavira-kuk9g4?file=/src/App.vue

Steps to Reproduce the Bug or Issue

  1. Go to https://codesandbox.io/s/awesome-mahavira-kuk9g4?file=/src/App.vue
  2. Observe the combo default type is rect
  3. Update the fixCollapseSize value from 5 -> 20 -> 50
  4. Observe the collapsed rect combo is growing in size
  5. Revert fixCollapseSize back to 5
  6. Change type to circle
  7. Update the fixCollapseSize value from 5 -> 20 -> 50
  8. Observe the collapsed circle combo is NOT growing in size

Expected behavior

As a user, I expected the combo with type circle to act the same as the combo type of rect

Screenshots or Videos

https://user-images.githubusercontent.com/16868336/179812220-ca2bbfcb-4ced-4643-9759-94e6ebf88153.mov

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: Chrome 103.0.5060.114 (Official Build) (arm64) macOS Monterey 12.4

Additional context

The documentation shows this as a property available https://g6.antv.vision/en/docs/manual/middle/elements/combos/built-in/circle#property

I see this code in /packages/core/src/element/combos/rect.ts

https://github.com/antvis/G6/blob/778720cc89866ba150ad6aeeb8695d5b41b4636f/packages/core/src/element/combos/rect.ts#L136

but the same code does not exist in /packages/core/src/element/combos/circle.ts

bsansone avatar Jul 19 '22 17:07 bsansone

fixCollapseSize in circle combo is ignored.

if (cfg.fixSize) {
  r = isNumber(cfg.fixSize) ? cfg.fixSize : cfg.fixSize[0];
} else {
  const size = (this as ShapeOptions).getSize!(cfg);
  if (!isNumber(style.r) || isNaN(style.r)) r = size[0] / 2 || Global.defaultCombo.style.r;
  else r = Math.max(style.r, size[0] / 2) || size[0] / 2;
}

maybe we can create a PR to fix it! 😄

alecthw avatar Jul 28 '22 12:07 alecthw

fixCollapseSize in circle combo is ignored.

if (cfg.fixSize) {
  r = isNumber(cfg.fixSize) ? cfg.fixSize : cfg.fixSize[0];
} else {
  const size = (this as ShapeOptions).getSize!(cfg);
  if (!isNumber(style.r) || isNaN(style.r)) r = size[0] / 2 || Global.defaultCombo.style.r;
  else r = Math.max(style.r, size[0] / 2) || size[0] / 2;
}

maybe we can create a PR to fix it! 😄

Great! Looking forward to it!

Yanyan-Wang avatar Jul 29 '22 02:07 Yanyan-Wang