From b2d4adf5b968e1c52096440f574b4169eb3a1672 Mon Sep 17 00:00:00 2001 From: notoraptor Date: Thu, 25 Jul 2019 16:34:10 -0400 Subject: Add select via shortcut (#61) - [web][select via dialog] Add shortcuts M and V. - [web][select via dialog] Asynchronously handle "select via" method, so that shortcut callback can continue to run (and then set its state) without waiting for callback return. This should help to prevent React from updating an unmounted shortcut component. --- diplomacy/web/src/gui/forms/select_via_form.jsx | 3 +++ diplomacy/web/src/gui/pages/content_game.jsx | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'diplomacy/web/src') diff --git a/diplomacy/web/src/gui/forms/select_via_form.jsx b/diplomacy/web/src/gui/forms/select_via_form.jsx index 8b340af..c0f13a5 100644 --- a/diplomacy/web/src/gui/forms/select_via_form.jsx +++ b/diplomacy/web/src/gui/forms/select_via_form.jsx @@ -18,6 +18,7 @@ import React from "react"; import PropTypes from "prop-types"; import {Button} from "../components/button"; import {FancyBox} from "../components/fancyBox"; +const HotKey = require('react-shortcut'); export class SelectViaForm extends React.Component { render() { @@ -27,6 +28,8 @@ export class SelectViaForm extends React.Component {
); diff --git a/diplomacy/web/src/gui/pages/content_game.jsx b/diplomacy/web/src/gui/pages/content_game.jsx index 457d901..a98c739 100644 --- a/diplomacy/web/src/gui/pages/content_game.jsx +++ b/diplomacy/web/src/gui/pages/content_game.jsx @@ -243,8 +243,10 @@ export class ContentGame extends React.Component { this.getPage().dialog(onClose => ( { - this.setSelectedVia(moveType, powerName, orderPath, location); - onClose(); + setTimeout(() => { + this.setSelectedVia(moveType, powerName, orderPath, location); + onClose(); + }, 0); }} onClose={() => { this.clearOrderBuildingPath(); -- cgit v1.2.3