Compare commits

...

1 Commits

Author SHA1 Message Date
Twirre Meulenbelt
a3aec5928c fix: allow parent updates to the TextField component
By setting an effect on the `value` prop, changes can be detected and the state can be updated.

ref: N25B-287
2025-11-13 12:23:44 +01:00

View File

@@ -1,4 +1,4 @@
import {useState} from "react"; import {useEffect, useState} from "react";
import styles from "./TextField.module.css"; import styles from "./TextField.module.css";
/** /**
@@ -86,6 +86,11 @@ export function TextField({
}) { }) {
const [inputValue, setInputValue] = useState(value); const [inputValue, setInputValue] = useState(value);
// The value may be changed from the outside, for example, when a program is loaded. We need to update the input value accordingly.
useEffect(() => {
setInputValue(value);
}, [value]);
const onCommit = () => setValue(inputValue); const onCommit = () => setValue(inputValue);
return <RealtimeTextField return <RealtimeTextField