Go js Group is not selectable

Hi Team,

I have simple group template and i want to define custom selection adornment to it, but it doesnt seem to work.

here is my code.

export const groupTemplate = (minWidth: number, minHeight: number, color: string, groupZOrder: zOrder) => {
  return $(
    Group,
    'Auto',
    groupShadow(),
    settings(),
    { selectable: true },
    { zOrder: groupZOrder },
    { minSize: new Size(minWidth, minHeight) },
    { layout: diagramTreeLayout() },
    { isLayoutPositioned: true },
    roundedPanel(
      color,
      true,
      'flowShape',
      { alignment: Spot.Center },
     selectionAdornment('flowShape'),
    ),
  );

export const selectionAdornment = (
  ...props: PartialShape[]
): { [selectionAdornmentTemplate: string]: Adornment } => {
  return {
    selectionAdornmentTemplate: $(
      Adornment,
      'Auto',
      $(Shape, 'RoundedRectangle', { parameter1: 4 }, { strokeWidth: 2, stroke: 'red' }, ...props),
      $(Placeholder),
    ),
  };
};

for some reason, it doesnt seem to work.

infact if i even remove the custom adornment, the default blue border should anyway show up around the group, but even that doesnt seem to show up on canvas, when i click over the group.

i also tried to to set { selectable: true }, , still no use.

is there anything wrong with my code and also i observed that the ChangedSelection event is never triggered on the diagram object, when I interact with the group.

diagram.addDiagramListener('ChangedSelection', (event: DiagramEvent) => {
    console.log('change event', event);
  });

any quick help would be really appreciated @walter

I don’t know what roundedPanel does, but I’m guessing it returns a Shape or a Panel. Alas, there’s no selectionAdornmentTemplate on the Shape class – it’s only defined on the Part class. You have to set that on your Group.

yes, you are right.

now its working as expected after i updated the code as per your advice.

thank you so much @walter :)