Skip to content

Commit

Permalink
Fix editor error in Safari due to availability of checkVisibility met…
Browse files Browse the repository at this point in the history
…hod (#65069)

* Fix editor error in Safari due to availability of checkVisibility method

* Add fallback approach if checkVisibility is not available

* Be specific about which Safari version we're talking about

Co-authored-by: Ramon <[email protected]>

---------

Co-authored-by: andrewserong <[email protected]>
Co-authored-by: ramonjd <[email protected]>
  • Loading branch information
3 people authored Sep 5, 2024
1 parent 4ba79a2 commit 179cffa
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/block-editor/src/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,26 @@ function isElementVisible( element ) {
return false;
}

return element.checkVisibility( {
opacityProperty: true,
contentVisibilityAuto: true,
visibilityProperty: true,
} );
// Older browsers, e.g. Safari < 17.4 may not support the `checkVisibility` method.
if ( element.checkVisibility ) {
return element.checkVisibility?.( {
opacityProperty: true,
contentVisibilityAuto: true,
visibilityProperty: true,
} );
}

const style = viewport.getComputedStyle( element );

if (
style.display === 'none' ||
style.visibility === 'hidden' ||
style.opacity === '0'
) {
return false;
}

return true;
}

/**
Expand Down

0 comments on commit 179cffa

Please sign in to comment.