Skip to content

theme-live-codeblock shows incorrect preview on theme change #9630

@NickGerleman

Description

@NickGerleman

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

If react-live LivePreview is re-rendered, it will peform preview from the LiveProvider code prop instead of the current state of the content.

I fixed this in something similar using theLiveEditor onChange prop, to keep state of the current code being edited, and passing that state to the LiveProvider instead of the original code.

Reproducible demo

No response

Steps to reproduce

  1. Go to https://docusaurus.io/docs/markdown-features/code-blocks#interactive-code-editor
  2. Add some text after the period in the output
  3. Change the theme

Expected behavior

The newly edited code is used for the preview

Actual behavior

The original code is used for the preview until a subsequent edit

Your environment

No response

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions