fabricjs / fabric.js

Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
http://fabricjs.com
Other
28.74k stars 3.49k forks source link

[Feature]: v6 API to Change a activeSelection to a normal group #9854

Open ouyoungs opened 4 months ago

ouyoungs commented 4 months ago

CheckList

Description

since v6 changes: https://github.com/fabricjs/fabric.js/issues/7670 this dosen't work now: http://fabricjs.com/manage-selection

is there any API to Change a activeSelection to a normal group? thx everyone!

Current State

Version

6.0.0-rc1

this dosn't work:

const objects = canvas.getActiveObjects()
canvas.discardActiveObject();
if (objects) {

    canvas.remove(...objects);
    const group = new Group();
    objects.forEach((obj) => {
        group.add(obj)
    })

    canvas.add(group);
    canvas.renderAll();
}

Additional Context

No response

gloriousjob commented 1 month ago

Does the current state code still not work? A rudimentary test seems fine and probably could be used to fix the demo (I would just do "new Group(objects)" instead of separating the forEach).