diff --git a/src/components/shortcuts/QuickActionsContextShortcuts.js b/src/components/shortcuts/QuickActionsContextShortcuts.js index b32dcd086..8e9777625 100644 --- a/src/components/shortcuts/QuickActionsContextShortcuts.js +++ b/src/components/shortcuts/QuickActionsContextShortcuts.js @@ -1,7 +1,28 @@ import React, { Component } from 'react'; import { Shortcuts } from 'react-shortcuts'; +/* TODO: Refactor this hack + * https://github.com/metasfresh/metasfresh-webui-frontend/issues/1283 + */ +let componentHierarchy = []; + class QuickActionsContextShortcuts extends Component { + componentWillMount() { + // Rerender components lower in the hierarchy when a new one is added + const _componentHierarchy = componentHierarchy; + componentHierarchy = [...componentHierarchy, this]; + + for (const component of _componentHierarchy) { + component.forceUpdate(); + } + } + + componentWillUnmount() { + componentHierarchy = componentHierarchy.filter( + component => component !== this + ); + } + handleShortcuts = (action, event) => { const {handleClick, onClick} = this.props; @@ -18,6 +39,11 @@ class QuickActionsContextShortcuts extends Component { } render() { + // Only render the top most component in the hierarchy + if (componentHierarchy[componentHierarchy.length - 1] !== this) { + return null; + } + return (