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 options arg to groupShapes method #3690

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Taha-Hassan-Git
Copy link
Contributor

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

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 May 3, 2024 11:40am
1 Ignored Deployment
Name Status Preview Updated (UTC)
tldraw-docs ⬜️ Ignored (Inspect) May 3, 2024 11:40am

@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.

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

2 participants