Skip to content

Commit

Permalink
Meta Boxes: Don't hide disabled meta boxes by modifying DOM (#12628)
Browse files Browse the repository at this point in the history
Hiding disabled meta boxes by setting `element.style.display = 'none'`
interferes with plugins like ACF which rely on being able to show and
hide meta boxes using `$.hide()` and `$.show()`.

Hiding the meta box using a new `.edit-post-meta-boxes-area .is-hidden`
class ensures that we don't interfere with third party code.
  • Loading branch information
noisysocks authored and youknowriad committed Dec 9, 2018
1 parent 1d5fa32 commit 06c4dc3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ class MetaBoxVisibility extends Component {

updateDOM() {
const { id, isVisible } = this.props;

const element = document.getElementById( id );
if ( element ) {
element.style.display = isVisible ? '' : 'none';
if ( ! element ) {
return;
}

if ( isVisible ) {
element.classList.remove( 'is-hidden' );
} else {
element.classList.add( 'is-hidden' );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
right: 20px;
z-index: z-index(".edit-post-meta-boxes-area .spinner");
}

// Hide disabled meta boxes using CSS so that we don't interfere with plugins
// that modify `element.style.display` on the meta box.
.is-hidden {
display: none;
}
}

.edit-post-meta-boxes-area__clear {
Expand Down

0 comments on commit 06c4dc3

Please sign in to comment.