Skip to content

Commit 1d42797

Browse files
committed
fix (inspector panels): in WP 5.9, clicking a closed panel only closes the current panel. fixes #2041
1 parent 22b344e commit 1d42797

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/components/panel-tabs/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class PanelTabs extends Component {
6868
this.select = this.select.bind( this )
6969
this.containerDiv = createRef()
7070

71+
// Auto-closing panels also re-triggers click listeners, this flag prevents that.
72+
this.suspendClickListener = false
73+
7174
this.props.onTabFirstOpen( this.state.activeTab )
7275
}
7376

@@ -116,8 +119,16 @@ class PanelTabs extends Component {
116119
return
117120
}
118121

122+
// Prevent re-triggering of this click listener when closing other panels below.
123+
if ( this.suspendClickListener ) {
124+
return
125+
}
126+
this.suspendClickListener = true
127+
119128
closeAllOpenPanels( toggle )
120-
this.props.onClickPanel( toggle.closest( '.components-panel__body' ) )
129+
130+
// Resume click handler.
131+
this.suspendClickListener = false
121132
}
122133

123134
select( tab ) {

0 commit comments

Comments
 (0)