Skip to content

Always switch to editor when it should #12820

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

Open
wants to merge 2 commits into
base: sandcastle-v2
Choose a base branch
from

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

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.

2 participants