Skip to content

Commit

Permalink
Fix patterns search crash: check for existence of defaultView before …
Browse files Browse the repository at this point in the history
…attempting to get styles (#52956)
  • Loading branch information
glendaviesnz authored and ramonjd committed Jul 28, 2023
1 parent dacafc0 commit 513443b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/editor-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ function useDarkThemeBodyClassName( styles ) {
body.appendChild( tempCanvas );

backgroundColor = defaultView
.getComputedStyle( tempCanvas, null )
?.getComputedStyle( tempCanvas, null )
.getPropertyValue( 'background-color' );

body.removeChild( tempCanvas );
} else {
backgroundColor = defaultView
.getComputedStyle( canvas, null )
?.getComputedStyle( canvas, null )
.getPropertyValue( 'background-color' );
}
const colordBackgroundColor = colord( backgroundColor );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useSelectionChangeCompat() {
return useRefEffect( ( element ) => {
const { ownerDocument } = element;
const { defaultView } = ownerDocument;
const selection = defaultView.getSelection();
const selection = defaultView?.getSelection();

let range;

Expand Down

0 comments on commit 513443b

Please sign in to comment.