Skip to content

Commit 68a38b9

Browse files
committed
refactor: make the NodeTextInput programmatically fillable
1 parent 332f729 commit 68a38b9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ui/components/NodeInputText.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ export const NodeInputText: FC<NodeInputProps> = ({
1212
dispatchSubmit,
1313
error,
1414
}) => {
15+
const [inputValue, setInputValue] = React.useState(attributes.value as string);
16+
1517
const urlParams = new URLSearchParams(window.location.search);
1618
const isWebauthn = urlParams.get("webauthn") === "true";
1719
const ucFirst = (s?: string) =>
@@ -26,10 +28,9 @@ export const NodeInputText: FC<NodeInputProps> = ({
2628
const isDuplicate = deduplicateValues.includes(value as string);
2729

2830
const message = node.messages.map(({ text }) => text).join(" ");
29-
const defaultValue = message.includes("Invalid login method")
30-
? (value as string)
31-
: message;
32-
31+
if (message) {
32+
setInputValue(message);
33+
}
3334
const getError = () => {
3435
if (message.startsWith("Invalid login method")) {
3536
return "Invalid login method";
@@ -60,7 +61,7 @@ export const NodeInputText: FC<NodeInputProps> = ({
6061
name={attributes.name}
6162
label={getNodeLabel(node)}
6263
disabled={disabled}
63-
defaultValue={defaultValue}
64+
value={inputValue}
6465
error={getError()}
6566
onChange={(e) => void setValue(e.target.value)}
6667
onKeyDown={(e) => {

0 commit comments

Comments
 (0)