Skip to content

Commit

Permalink
Only check for errors on blur instead of onChange
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Jan 25, 2023
1 parent 1ee3e75 commit 226002e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/edit-site/src/components/global-styles/custom-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,18 @@ function CustomCSSControl( { blockName } ) {
return;
}
setCustomCSS( value );
// TODO: transform it to find syntax error. Note that it will be transformed again
// after applied to the preview frame. We should refactor this to prevent double-transform.
if ( cssError ) {
const [ transformed ] = transformStyles(
[ { css: value } ],
'.editor-styles-wrapper'
);
if ( transformed ) {
setCSSError( null );
}
}
}

function handleOnBlur( value ) {
const [ transformed ] = transformStyles(
[ { css: value } ],
'.editor-styles-wrapper'
Expand All @@ -74,6 +84,7 @@ function CustomCSSControl( { blockName } ) {
themeCustomCSS
}
onChange={ ( value ) => handleOnChange( value ) }
onBlur={ handleOnBlur }
rows={ 15 }
className="edit-site-global-styles__custom-css-input"
spellCheck={ false }
Expand Down

0 comments on commit 226002e

Please sign in to comment.