Fixed initial onChange on all components

This commit is contained in:
Lucas Oliveira 2023-12-31 12:10:24 -03:00
commit 081b6a63be
5 changed files with 7 additions and 7 deletions

View file

@ -19,11 +19,11 @@ export default function CodeAreaComponent({
typeof value == "string" ? value : JSON.stringify(value)
);
useEffect(() => {
if (disabled) {
if (disabled && myValue !== "") {
setMyValue("");
onChange("");
}
}, [disabled, onChange]);
}, [disabled]);
useEffect(() => {
setMyValue(typeof value == "string" ? value : JSON.stringify(value));

View file

@ -15,10 +15,10 @@ export default function FloatComponent({
const max = rangeSpec?.max ?? 2;
// Clear component state
useEffect(() => {
if (disabled) {
if (disabled && value !== "") {
onChange("");
}
}, [disabled, onChange]);
}, [disabled]);
return (
<div className="w-full">

View file

@ -13,7 +13,7 @@ export default function InputListComponent({
editNode = false,
}: InputListComponentType): JSX.Element {
useEffect(() => {
if (disabled) {
if (disabled && value.length > 0 && value[0] !== "") {
onChange([""]);
}
}, [disabled]);

View file

@ -14,7 +14,7 @@ export default function KeypairListComponent({
duplicateKey,
}: KeyPairListComponentType): JSX.Element {
useEffect(() => {
if (disabled) {
if (disabled && value.length > 0 && value[0] !== "") {
onChange([""]);
}
}, [disabled]);

View file

@ -14,7 +14,7 @@ export default function TextAreaComponent({
}: TextAreaComponentType): JSX.Element {
// Clear text area
useEffect(() => {
if (disabled) {
if (disabled && value !== "") {
onChange("");
}
}, [disabled]);