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

fix(sandpack-react): fix autoReload and honor showRunButton false #907

Merged
merged 3 commits into from
Apr 17, 2023

Conversation

zachmerrill
Copy link
Contributor

What kind of change does this pull request introduce?

This fixes a bug where autoReload={false} doesn't turn off auto reload on code change. Additionally, it changes the logic for the Run button so that showRunButton={false} is honored even when autoReload is off.

What is the current behavior?

  1. When autoReload is set to false and a file is edited, the preview automatically reloads anyway.
  2. When both autoReload and showRunButton are set to false the code editor shows the Run button.

What is the new behavior?

  1. autoReload={false} will prevent the preview from reloading when the code changes.
  2. showRunButton={false} will prevent the Run button from ever appearing.

What steps did you take to test this? This is required before we can merge, make sure to test the flow you've updated.

  1. In Storybook, test PRESETS > Sandpack: options > Auto Reload. Adjusting the code should not trigger a reload of the preview.
  2. I also played with the basic component example in sandpack-react/src/components/CodeEditor/CodeEditor.stories.tsx using Storybook to test when the Run button was shown or hidden.
    The following will hide the Run button and not automatically reload the preview:
export const Component: Story<CodeEditorProps> = (args) => (
  <SandpackProvider
    options={{
      autoReload: false,
    }}
  >
    <SandpackThemeProvider>
      <SandpackCodeEditor {...args} showRunButton={false} />
      <SandpackPreview />
    </SandpackThemeProvider>
  </SandpackProvider>
);

Checklist

  • Documentation;
  • Storybook (if applicable);
  • Tests;
  • Ready to be merged;

@vercel
Copy link

vercel bot commented Apr 14, 2023

@zachmerrill is attempting to deploy a commit to the CodeSandbox Team on Vercel.

A member of the Team first needs to authorize it.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 14, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1436ca4:

Sandbox Source
Sandpack Configuration
sandpack-run-stale-value Configuration

Copy link
Member

@danilowoz danilowoz left a comment

Choose a reason for hiding this comment

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

It looks good to me. Thank you

@danilowoz danilowoz merged commit 63c89e3 into codesandbox:main Apr 17, 2023
4 of 6 checks passed
@zachmerrill
Copy link
Contributor Author

It looks good to me. Thank you

No problem! I really like Sandpack. Happy to help 😁

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.

None yet

2 participants