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

Add select option to Editor.groupShapes and Editor.ungroupShapes #3690

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

Taha-Hassan-Git
Copy link
Contributor

@Taha-Hassan-Git Taha-Hassan-Git commented May 3, 2024

This PR adds an (optional) options argument to the Editor.groupShapes and Editor.ungroupShapes methods.

Taha's original PR:

This PR seeks to make it easier to disentangle shape selection logic from the grouping shapes logic. This is one of two approaches we could take to this problem.

Other PR is here: #3691

I think this is a better method because it doesn't require consumers of the library with their own custom actions to change the way their own grouping logic works. As evidenced by all the tests failing on the other PR.

Change Type

  • sdk — Changes the tldraw SDK
  • dotcom — Changes the tldraw.com web app
  • docs — Changes to the documentation, examples, or templates.
  • vs code — Changes to the vscode plugin
  • internal — Does not affect user-facing stuff
  • bugfix — Bug fix
  • feature — New feature
  • improvement — Improving existing features
  • chore — Updating dependencies, other boring stuff
  • galaxy brain — Architectural changes
  • tests — Changes to any test code
  • tools — Changes to infrastructure, CI, internal scripts, debugging tools, etc.
  • dunno — I don't know

Test Plan

  1. Add a step-by-step description of how to test your PR here.
  • Unit Tests
  • End to end tests

Release Notes

  • Add a brief release note for your PR here.

Copy link

vercel bot commented May 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
examples ✅ Ready (Inspect) Visit Preview Jun 3, 2024 9:05am
1 Ignored Deployment
Name Status Preview Updated (UTC)
tldraw-docs ⬜️ Ignored (Inspect) Visit Preview Jun 3, 2024 9:05am

@Taha-Hassan-Git Taha-Hassan-Git marked this pull request as ready for review May 3, 2024 11:42
@huppy-bot huppy-bot bot added improvement Improves existing features sdk Affects the tldraw sdk labels May 3, 2024
Comment on lines 6592 to 6593
groupId = createShapeId(),
options: TLGroupShapesOptions = { selectAfterGrouping: true }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to combine these into one options argument while preserving backwards compatibility. something like this

export type TLGroupShapesOptions = {
	selectAfterGrouping?: boolean
  shapeId?: string
}

// ...


groupShapes(shapes: TLShapeId[] | TLShape[], options: TLGroupShapesOptions | TLShapeId = {}) {
  if (typeof options === 'string') {
    options = { groupId: options }
  }

  // ...
}

That way we keep the 'options' a bit tidier.

@steveruizok steveruizok changed the title Add options arg to groupShapes method Add select option to Editor.groupShapes and Editor.ungroupShapes Jun 3, 2024
@steveruizok steveruizok added this pull request to the merge queue Jun 3, 2024
Merged via the queue into main with commit 14abf25 Jun 3, 2024
10 checks passed
@steveruizok steveruizok deleted the taha/groupshapes-options branch June 3, 2024 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves existing features sdk Affects the tldraw sdk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants