re-fixes ComplexModal.js to use UIDs (I lasted 10 minutes having to watch this break you know who you are medbay player) (#4344)

* Update ComplexModal.js

* Update ComplexModal.js

* Update ComplexModal.js
This commit is contained in:
silicons
2022-08-11 16:57:33 -07:00
committed by GitHub
parent 6fbdd4df25
commit fd6ba84e59

View File

@@ -1,4 +1,4 @@
import { useBackend } from "../../backend";
import { useBackend, useLocalState } from "../../backend";
import { Box, Button, Dropdown, Flex, Input, Modal } from '../../components';
let bodyOverrides = {};
@@ -77,6 +77,7 @@ export const ComplexModal = (props, context) => {
id,
text,
type,
uid,
} = data.modal;
let modalOnEnter;
@@ -94,7 +95,7 @@ export const ComplexModal = (props, context) => {
if (bodyOverrides[id]) {
modalBody = bodyOverrides[id](data.modal, context);
} else if (type === "input") {
let curValue = data.modal.value;
const [curValue, setCurValue] = useLocalState(context, 'curValue' + data.modal.uid.toString(), data.modal.value.toString());
modalOnEnter = e => modalAnswer(context, id, curValue);
modalBody = (
<Input
@@ -105,7 +106,7 @@ export const ComplexModal = (props, context) => {
autoFocus
autoSelect
onChange={(_e, val) => {
curValue = val;
setCurValue(val);
}}
/>
);