Skip to content

[BUG] Group rotation doesn't works #927

@VladimirIvakhnenko

Description

@VladimirIvakhnenko

Group rotation doesn't works

Group rotation via rotation handle does not rotate the group and its children.

When multiple elements are grouped and the rotation handle is used on the group, the rotation is not applied to the group nor to the nested elements. The interaction completes without committing the rotation.

No rotation is committed on mouse release: the group and its nested elements remain unrotated (or rotate around an incorrect pivot during drag but revert/are not applied on release).

To Reproduce

Steps to reproduce the behavior:

  1. Group several elements.
  2. Press and hold the right mouse button on the group’s rotation handle.
  3. Move the cursor to rotate the group.
  4. Release the right mouse button.

If possible provide a repository to reproduce the issue. At minimum, provide the code (in text form, no image) that produces the issue.

Expected behavior

The group rotates around the correct pivot, and all nested elements rotate together with the group.

Screenshots

Image Image

Environment

  • maxGraph version: 0.21.0
  • Desktop
  • OS and version: Windows 11
  • Browser and version: [e.g. chrome 141]
  • Used frameworks: Angular v16.2

Additional context

Graph configuration:

VertexHandlerConfig.rotationEnabled = true;
    VertexHandlerConfig.cursorMovable = 'move';
    EdgeHandlerConfig.virtualBendsEnabled = true;
    graph.setCellsBendable(true);
    graph.setPanning(true);
    graph.setHtmlLabels(true);
    graph.setGridEnabled(true);
    graph.setGridSize(10);
    graph.setPanning(true);
    graph.setAllowDanglingEdges(true);
    graph.resetEdgesOnConnect = false;
    graph.setRecursiveResize(true);
    graph.setConstrainRelativeChildren(true);

groupCells method:

if (!graph) return;
      const selectedCells = graph.getSelectionCells();

      try {
        graph.getDataModel().beginUpdate();

        const cells = graph.getCellsForGroup(selectedCells);
        console.log(cells);

        if (cells.length > 1) {
          graph.createGroupCell;
          const group = graph.groupCells(null as any, 0, cells);

          graph.setCellStyle(
            {
              ...group.style,
              shape: 'rectangle',
              fillColor: 'none',
              strokeColor: 'none',
              rotatable: true,
              resizable: true,
            },
            [group]
          );

          graph.setSelectionCell(group);
        }
      } finally {
        graph.getDataModel().endUpdate();
      } 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageIssue/PR under review for categorization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions