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 CodeEditor not loading when WordPress is installed in a subfolder #6777

Merged
merged 9 commits into from
May 23, 2018
2 changes: 1 addition & 1 deletion components/code-editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class CodeEditor extends Component {
}

render() {
return <textarea ref={ ( ref ) => ( this.textarea = ref ) } value={ this.props.value } />;
return <textarea ref={ ( ref ) => ( this.textarea = ref ) } defaultValue={ this.props.value } />;
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/code-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function loadScript() {
}

const script = document.createElement( 'script' );
script.src = `/wp-admin/load-scripts.php?load=${ handles.join( ',' ) }`;
script.src = `${ wpApiSettings.schema.url }/wp-admin/load-scripts.php?load=${ handles.join( ',' ) }`;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably not the only place where we use this, but we should move away from using globals. I'm also wondering if the CodeEditor belongs in the components module since the components module is supposed to be for generic components (without WP dependency?).

Anyway, this is not urgent and will have to be figured out when we move components to an npm dependency anyway. And this is not specific to this component.

script.onload = resolve;
script.onerror = reject;

Expand All @@ -35,7 +35,7 @@ function loadStyle() {

const style = document.createElement( 'link' );
style.rel = 'stylesheet';
style.href = `/wp-admin/load-styles.php?load=${ handles.join( ',' ) }`;
style.href = `${ wpApiSettings.schema.url }/wp-admin/load-styles.php?load=${ handles.join( ',' ) }`;
style.onload = resolve;
style.onerror = reject;

Expand Down
2 changes: 1 addition & 1 deletion components/code-editor/test/__snapshots__/editor.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

exports[`CodeEditor should render without an error 1`] = `
<textarea
value="<b>wowee</b>"
defaultValue="<b>wowee</b>"
/>
`;