From 89e67b315089a249e2672ab5b83e3f8adbf23d24 Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Tue, 31 Mar 2020 08:06:13 -0700 Subject: [PATCH] Better detection for action screen. --- src/components/farm/Board.jsx | 37 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/components/farm/Board.jsx b/src/components/farm/Board.jsx index 4f7a5e0..3f5ce79 100644 --- a/src/components/farm/Board.jsx +++ b/src/components/farm/Board.jsx @@ -1232,17 +1232,19 @@ class Action extends React.Component { } } return ( - - -
- {view} -
-
-
- {this.props.otherPlayersTurn ? () : buttons} -
- -
+
this.props.forwardRef(x)}> + + +
+ {view} +
+
+
+ {this.props.otherPlayersTurn ? () : buttons} +
+ +
+
); } } @@ -1447,6 +1449,13 @@ class BoardApp extends React.Component { card: props.ui.card }; this.myRef = React.createRef(); + this.actionRef = React.createRef(); + this.actionRefExtra = React.createRef(); + } + + actionShowing = () => { + return (this.actionRef && this.actionRef.offsetParent) || + (this.actionRefExtra && this.actionRefExtra.offsetParent) } showScreen = screen => { @@ -1475,7 +1484,7 @@ class BoardApp extends React.Component { // it as handled. if (this.props.ui.unhandledAlert && this.props.ui.unhandledAlert.type === ALERTS.beginTurn && - this.state.screen === SCREENS.action) { + this.actionShowing()) { this.props.alertHandled(this.props.ui.unhandledAlert.id); } } @@ -1567,7 +1576,7 @@ class BoardApp extends React.Component { ); - } else if (alert && this.state.screen !== SCREENS.action) { + } else if (alert && !this.actionShowing()) { switch (alert.type) { case ALERTS.beginTurn: alertOverlay = ( @@ -1651,6 +1660,7 @@ class BoardApp extends React.Component {
this.actionRef = x} spaces={this.props.spaces} player={this.props.player} game={this.props.game} @@ -1699,6 +1709,7 @@ class BoardApp extends React.Component {
this.actionRefExtra = x} spaces={this.props.spaces} player={this.props.player} game={this.props.game}