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

SandBox not re-rendered after HTML changes #16831

Closed
mmtr opened this issue Jul 31, 2019 · 2 comments · Fixed by #20176
Closed

SandBox not re-rendered after HTML changes #16831

mmtr opened this issue Jul 31, 2019 · 2 comments · Fixed by #20176
Assignees
Labels
[Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@mmtr
Copy link
Contributor

mmtr commented Jul 31, 2019

Describe the bug
The SandBox component from the @wordpress/components package is not re-rendered when the injected html prop changes.

To reproduce

  • Paste the following code in playground/src/index.js:
import { render, useState, Fragment } from '@wordpress/element';
import { SandBox, SelectControl } from '@wordpress/components';
import './style.scss';
import '@wordpress/components/build-style/style.css';

function App() {
	const [ fruit, setFruit ] = useState( 'Bananas' );
	const html = `<div>Selected fruit: <strong>${ fruit }</strong>!</div>`;

	return (
		<Fragment>
			<SelectControl
				label="Fruit"
				value={ fruit }
				options={ [
					{ label: 'Bananas', value: 'Bananas' },
					{ label: 'Oranges', value: 'Oranges' },
					{ label: 'Apples', value: 'Apples' },
				] }
				onChange={ ( value ) => { setFruit( value ) } }
			/>
			<SandBox html={ html } />
		</Fragment>
	);
}

render(
	<App />,
	document.querySelector( '#app' )
);
  • Run npm run playground:start.
  • Go to http://localhost:1234.
  • Select any other fruit than Bananas.

Expected behavior
The selected fruit text displayed below the fruit selector should be updated after selecting any other fruit, but it keeps unchanged:

Screenshots
Screen Shot 2019-07-31 at 14 32 38

@mmtr mmtr added [Type] Bug An existing feature does not function as intended [Package] Components /packages/components labels Jul 31, 2019
@swissspidy
Copy link
Member

Sounds like a duplicate of #16612.

Can you test #16669 to see if that fixes the issue?

@mmtr
Copy link
Contributor Author

mmtr commented Aug 1, 2019

Sounds like a duplicate of #16612.

Can you test #16669 to see if that fixes the issue?

I don't think it's related to #16612. I verified I can still reproduce the issue with #16669.

Seems to be more a problem on how the SandBox component is implemented. The render function doesn't use at all the html prop, which is why any change to that prop doesn't trigger any update. The html prop is only used on trySandbox, but that method is only called after the SandBox component has been already rendered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants