tldraw icon indicating copy to clipboard operation
tldraw copied to clipboard

[bug] Group shape behavior

Open steveruizok opened this issue 4 years ago • 4 comments

Something's up with group behavior.

Kapture 2021-11-26 at 15 09 59

  • create a rectangle
  • create text
  • group shapes
  • double click text to select it
  • double click text to edit it
  • click outside to blur text
  • move text or rectangle around

steveruizok avatar Nov 26 '21 16:11 steveruizok

Hi @steveruizok I have some idea about this issue:

When the user clicks on some children in a group, the logic in SelectTool.ts will set the selectedGroupId into some value, but when the user clicks outside of the group, or, on the canvas, there's no logic to clean up the selectedGroupId. That's why the second time user click on the group, it will directly drill in and select the children.

you might want to try to handle the clean up in onPointDown(), and also when user press the Esc key to remove focus from the selection:

onPointerDown: TLPointerEventHandler = (info, e) => {
  ...
  if (info.target === 'canvas' && this.status === Status.Idle) {
    this.selectedGroupId = undefined
    ...
  }
  ...
}

lichin-lin avatar Dec 25 '21 08:12 lichin-lin

Thanks for the analysis! Want to make a PR? If not, I can come back to this in a few days and try to apply your fix.

steveruizok avatar Dec 25 '21 08:12 steveruizok

yes! I am working on it! but somehow one of the test cases in SelectTool.spec.ts can't pass (Edits grouped text on double click after selecting) 😢, the double click behavior is different when it happens in the test env versus actual user triggering it.

lichin-lin avatar Dec 27 '21 02:12 lichin-lin

Right on! Don't worry about that, feel free to skip the test or write it as a todo. (It may be an issue with the tests themselves).

steveruizok avatar Dec 27 '21 08:12 steveruizok

it has been fixed!

judicaelandria avatar Aug 19 '22 13:08 judicaelandria