Make default sketch canvas ID autoincrement #7836
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #7834
Changes:
There are two parts to this PR, the first is to not assign an ID to the canvas element if it already has an ID thereby preserving the user intended one.
The second part makes the default ID (assigned when the canvas don't already have an ID) to have an autoincrementing number. This is done so that if there are multiple sketches created by the user, they will not all be assigned the same ID which is technically not good practice (ID should be unique). However, I'm not sure if this is the right approach because I'm also thinking whether we should assign default ID's to sketch canvas at all.
We already add a class to the canvas so they can be collectively selected if needed while the ID along with the autoincrementing aspect makes the numbering potentially unstable and so may not be entirely reliable as a selector. The ID is not used internally and externally it probably shouldn't be relied on to be a specific value since the ID is something that the user can change. So another potential solution is to remove the sketch ID assignment entirely.