mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
BUGFIX: Prompt does not reset text value (#1539)
This commit is contained in:
parent
1ed47b4bc9
commit
7c7293b687
@ -52,8 +52,9 @@ export function PromptManager({ hidden }: { hidden: boolean }): React.ReactEleme
|
||||
};
|
||||
|
||||
let PromptContent = PromptMenuBoolean;
|
||||
if (prompt?.options?.type && ["text", "select"].includes(prompt.options.type))
|
||||
if (prompt?.options?.type && ["text", "select"].includes(prompt.options.type)) {
|
||||
PromptContent = types[prompt.options.type];
|
||||
}
|
||||
const resolve = (value: boolean | string): void => {
|
||||
prompt?.resolve(value);
|
||||
setPrompt(null);
|
||||
@ -94,10 +95,17 @@ function PromptMenuBoolean({ resolve }: IContentProps): React.ReactElement {
|
||||
);
|
||||
}
|
||||
|
||||
function PromptMenuText({ resolve }: IContentProps): React.ReactElement {
|
||||
function PromptMenuText({ prompt, resolve }: IContentProps): React.ReactElement {
|
||||
const [value, setValue] = useState("");
|
||||
|
||||
const submit = (): void => resolve(value);
|
||||
const submit = (): void => {
|
||||
resolve(value);
|
||||
setValue("");
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setValue("");
|
||||
}, [prompt]);
|
||||
|
||||
const onInput = (event: React.ChangeEvent<HTMLInputElement>): void => {
|
||||
setValue(event.target.value);
|
||||
@ -133,7 +141,14 @@ function PromptMenuText({ resolve }: IContentProps): React.ReactElement {
|
||||
function PromptMenuSelect({ prompt, resolve }: IContentProps): React.ReactElement {
|
||||
const [value, setValue] = useState("");
|
||||
|
||||
const submit = (): void => resolve(value);
|
||||
const submit = (): void => {
|
||||
resolve(value);
|
||||
setValue("");
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setValue("");
|
||||
}, [prompt]);
|
||||
|
||||
const onChange = (event: SelectChangeEvent): void => {
|
||||
setValue(event.target.value);
|
||||
@ -158,7 +173,11 @@ function PromptMenuSelect({ prompt, resolve }: IContentProps): React.ReactElemen
|
||||
return (
|
||||
<>
|
||||
<div style={{ display: "flex", alignItems: "center", paddingTop: "10px" }}>
|
||||
<Select onChange={onChange} value={value} style={{ flex: "1 0 auto" }}>
|
||||
<Select
|
||||
onChange={onChange}
|
||||
value={prompt.options?.choices.includes(value) ? value : ""}
|
||||
style={{ flex: "1 0 auto" }}
|
||||
>
|
||||
{getItems(prompt.options?.choices || [])}
|
||||
</Select>
|
||||
<Button onClick={submit} disabled={value === ""}>
|
||||
|
Loading…
Reference in New Issue
Block a user