From e511f723e57dde0fc4bf1069763d2cd7c38ff2dc Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 28 Aug 2019 08:07:46 +0200 Subject: [PATCH] fix PageAction detection by using a static class property --- .../packages/ui-components/src/layout/Page.js | 9 +++++++-- .../packages/ui-components/src/layout/PageActions.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scm-ui-components/packages/ui-components/src/layout/Page.js b/scm-ui-components/packages/ui-components/src/layout/Page.js index c7a7f66cf4..622c4b429c 100644 --- a/scm-ui-components/packages/ui-components/src/layout/Page.js +++ b/scm-ui-components/packages/ui-components/src/layout/Page.js @@ -44,6 +44,11 @@ class Page extends React.Component { ); } + isPageAction(node: any) { + return node.displayName === PageActions.displayName + || (node.type && node.type.displayName === PageActions.displayName); + } + renderPageHeader() { const { error, title, subtitle, children, classes } = this.props; @@ -51,7 +56,7 @@ class Page extends React.Component { let pageActionsExists = false; React.Children.forEach(children, child => { if (child && !error) { - if (child.displayName === PageActions.displayName) { + if (this.isPageAction(child)) { pageActions = (
{ let content = []; React.Children.forEach(children, child => { if (child) { - if (child.displayName !== PageActions.displayName) { + if (!this.isPageAction(child)) { content.push(child); } } diff --git a/scm-ui-components/packages/ui-components/src/layout/PageActions.js b/scm-ui-components/packages/ui-components/src/layout/PageActions.js index d713e8ce11..98f0a21634 100644 --- a/scm-ui-components/packages/ui-components/src/layout/PageActions.js +++ b/scm-ui-components/packages/ui-components/src/layout/PageActions.js @@ -9,7 +9,7 @@ type Props = { }; export default class PageActions extends React.Component { - displayName: string = "PageActions"; + static displayName = "PageActions"; render() { return <>{this.renderContent()};