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

[Bug]: rc2 break ActiveSelection if through group select #9938

Closed
7 tasks done
ritali4912 opened this issue Jun 24, 2024 · 7 comments · Fixed by #9940
Closed
7 tasks done

[Bug]: rc2 break ActiveSelection if through group select #9938

ritali4912 opened this issue Jun 24, 2024 · 7 comments · Fixed by #9940
Labels

Comments

@ritali4912
Copy link

ritali4912 commented Jun 24, 2024

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have read and followed the Issue Tracker Guide
  • I have searched and referenced existing issues and discussions
  • I am filing a BUG report.
  • I have managed to reproduce the bug after upgrading to the latest version
  • I have created an accurate and minimal reproduction

Version

6.0.0-rc2

In What environments are you experiencing the problem?

Microsoft Edge

Node Version (if applicable)

None

Link To Reproduction

https://jsfiddle.net/ritali4912/deartfzo/30/

Steps To Reproduce

  1. Create 2 rect
  2. Make them in ActiveSelection through group select (mouse down then move to select them)
  3. Check the Active Selection

image

Expected Behavior

In beta 20, it is correct.
image

Actual Behavior

In rc2, the bounds of the ActiveSelection change to {left: 0, top: 0, width: 0, height: 0}
image

I check the code, and found it caused by the improper set properties timing. Especially If the user change the originX, originY which will impact on the layout result.
And with bellow change, I can get correct result.
Please evaluate and help to fix it in next release.

image

Error Message & Stack Trace

No response

@asturur
Copy link
Member

asturur commented Jun 24, 2024

hi @ritali4912 can you check the latest master? it seems ok to me. I think we also have a test case for this interaction (i'll verify )

@asturur
Copy link
Member

asturur commented Jun 24, 2024

i updated rc3, let me know if it changes anything, otherwise i ll mark as a bug and fix

@asturur
Copy link
Member

asturur commented Jun 24, 2024

ok i see the point, i have to uncomment the originX to actually make the issue happen with latest master.
Please make tidier reproduction case:

actual reproduction case

export async function testCase(canvas: fabric.Canvas) {
  const utahCommonDefaults = {
    originX: 'center' as const,
    originY: 'center' as const,
  };

  fabric.ActiveSelection.ownDefaults = {
    ...fabric.ActiveSelection.ownDefaults,
    ...utahCommonDefaults,
  };

  fabric.Rect.ownDefaults = {
    ...fabric.Rect.ownDefaults,
    ...utahCommonDefaults,
  };

  const rect = new fabric.Rect({ width: 500, height: 500, fill: 'blue' });
  const rect2 = new fabric.Rect({ width: 500, height: 500, fill: 'blue' });

  canvas.add(rect, rect2);
}

@ritali4912
Copy link
Author

@asturur
Yes, I just update to rc3, the issue still here.
If you make the ActiveSelection through mouse click rect1 + shift click rect2, it is correct.
But group select is wrong.

As my above picture.
The below code initial the ActiveSelection with default properties, for example: originX: left, originY: top
and return with a bound based on {left, top}.
super(objects, { layoutManager: layoutManager ?? new ActiveSelectionLayoutManager() });

But then the follow code with set the bound to all 0.
Object.assign(this, ActiveSelection.ownDefaults); this.setOptions(options);

@ritali4912
Copy link
Author

@asturur
Ah, I'm sorry for the uncomment code.
Yes, in my case, I need the originX: 'center', originY: 'center'.

But from the logic, I think it is no matter what value of originX, originX.

@asturur
Copy link
Member

asturur commented Jun 24, 2024

@ritali4912 check the fix here: #9940 and please have a look that the added e2e test represent your use case

@ritali4912
Copy link
Author

@asturur
I verified the 9940, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants