Fix panel toggle for Gutenberg 9.1

[MAILPOET-3154]
This commit is contained in:
Pavel Dohnal
2020-10-07 11:08:51 +02:00
committed by Veljko V
parent eb75c0c6c5
commit 14b6b88f9b
2 changed files with 6 additions and 16 deletions

View File

@@ -21,11 +21,11 @@ const getRequiredAction = (openedPanels, panelId, toggleTo) => {
* @return {object} Modified state object
*/
export default (state, action) => {
if (action.toggleTo !== undefined && !['opened', 'closed'].includes(action.toggleTo)) {
throw new Error(`Unexpected toggleTo value "${action.toggleTo}"`);
}
let toggleTo;
if (action.toggleTo === true) toggleTo = 'opened';
if (action.toggleTo === false) toggleTo = 'closed';
const openedPanels = [...state.sidebar.openedPanels];
const requiredAction = getRequiredAction(openedPanels, action.id, action.toggleTo);
const requiredAction = getRequiredAction(openedPanels, action.id, toggleTo);
if (requiredAction === 'open') {
openedPanels.push(action.id);
} else if (requiredAction === 'close') {