Skip to content

Conversation

jjspace
Copy link
Contributor

@jjspace jjspace commented Aug 14, 2025

Description

Fixes a bug when you have a specific sandcastle loaded and click the "Open code" button on that same sandcastle in the gallery

Issue number and link

Part of #12566

Testing plan

  • Run sandcastle with npm run dev in the package or npm run build-sandcastle and npm start at the project root
  • Open the gallery and click any sandcastle
  • Once it's loaded click the "Open code" button for that same sandcastle
  • it should switch to the code and reload the sandcastle

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@jjspace jjspace requested a review from lukemckinstry August 14, 2025 18:58
Copy link

Thank you for the pull request, @jjspace!

✅ We can confirm we have a CLA on file for you.

@lukemckinstry
Copy link
Contributor

lukemckinstry commented Aug 15, 2025

I notice when I click the "open code" button for a sandcastle that is already open, it reloads the scene in the viewer. This seems unnecessary. Can we skip this?

I see toggling the "gallery" and "editor" buttons does not reload the scene in the viewer, which seems better.

@jjspace
Copy link
Contributor Author

jjspace commented Aug 19, 2025

I notice when I click the "open code" button for a sandcastle that is already open, it reloads the scene in the viewer.

This was intentional to keep the behavior consistent. If you click the card for a gallery item it will load it even if it is already loaded. I meant this to be a way to "re-run" without switching to the code panel. I think this is good.
I left this behavior for the switch to code button too to make sure it's starting "fresh" when viewing the code but I realize it may be a bit too much. I've updated the code to avoid re-running when switching to code and it's already loaded.

(The "active" detection is a little messy now relying on the url. I plan to change this a bit later based on some other open PRs but not in this one to avoid conflicts)

Copy link
Contributor

@lukemckinstry lukemckinstry left a comment

Choose a reason for hiding this comment

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

Good to go once CI is passing

@jjspace
Copy link
Contributor Author

jjspace commented Aug 27, 2025

@lukemckinstry I've merged in the changes to prevent leaving with pending changes. I believe this should be good to merge now?

Copy link
Contributor

@ggetz ggetz left a comment

Choose a reason for hiding this comment

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

@jjspace I want to clarify the behavior here, as per my comment below.

Otherwise, I don't see any issues with the code.

}
setLeftPanel("editor");
} else {
// Load the gallery item every time it's clicked ro act as a "rerun" button
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Load the gallery item every time it's clicked ro act as a "rerun" button
// Load the gallery item every time it's clicked to act as a "rerun" button

But moreover, I agree with Luke that this seems like confusing behavior.

This was intentional to keep the behavior consistent. If you click the card for a gallery item it will load it even if it is already loaded. I meant this to be a way to "re-run" without switching to the code panel. I think this is good.

Why do we need to rerun from the gallery list at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this behavior there is (currently) no way to "re-run" or reset a sandcastle without first switching to the code view. I don't know about others but I personally find I often want to reset sandcastles if I've moved the camera or edited values and just want a quick way to get back to the "start". Maybe we need to move the Run button or duplicate it but for now this solution felt like a good compromise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ggetz did you have thoughts around this?

@jjspace
Copy link
Contributor Author

jjspace commented Sep 2, 2025

Possibly replaced by some of the logic in #12854, revisit later

Base automatically changed from sandcastle-v2 to main September 3, 2025 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants