🐛 fix(EditNodeModal): setAdv state variable to null initially to avoid undefined value

🐛 fix(types): change advanced prop type in KeyPairListComponentType to allow null value
This commit is contained in:
Cristhian Zanforlin Lousa 2023-09-28 18:41:26 -03:00
commit 9d9a1177f2
2 changed files with 16 additions and 18 deletions

View file

@ -76,6 +76,7 @@ const EditNodeModal = forwardRef(
function changeAdvanced(n) { function changeAdvanced(n) {
myData.current.node!.template[n].advanced = myData.current.node!.template[n].advanced =
!myData.current.node!.template[n].advanced; !myData.current.node!.template[n].advanced;
setAdv(!adv);
} }
const handleOnNewValue = (newValue: any, name) => { const handleOnNewValue = (newValue: any, name) => {
@ -88,6 +89,7 @@ const EditNodeModal = forwardRef(
}, [modalOpen]); }, [modalOpen]);
const [errorDuplicateKey, setErrorDuplicateKey] = useState(false); const [errorDuplicateKey, setErrorDuplicateKey] = useState(false);
const [adv, setAdv] = useState<boolean | null>(null);
return ( return (
<BaseModal <BaseModal
@ -266,11 +268,7 @@ const EditNodeModal = forwardRef(
)} )}
> >
<KeypairListComponent <KeypairListComponent
advanced={ advanced={adv}
myData.current.node?.template[
templateParam
].advanced
}
disabled={disabled} disabled={disabled}
editNode={true} editNode={true}
value={ value={

View file

@ -61,7 +61,7 @@ export type KeyPairListComponentType = {
disabled: boolean; disabled: boolean;
editNode?: boolean; editNode?: boolean;
duplicateKey?: boolean; duplicateKey?: boolean;
advanced?: boolean; advanced?: boolean | null;
}; };
export type DictComponentType = { export type DictComponentType = {
@ -135,18 +135,18 @@ export type TooltipComponentType = {
children: ReactElement; children: ReactElement;
title: string | ReactElement; title: string | ReactElement;
placement?: placement?:
| "bottom-end" | "bottom-end"
| "bottom-start" | "bottom-start"
| "bottom" | "bottom"
| "left-end" | "left-end"
| "left-start" | "left-start"
| "left" | "left"
| "right-end" | "right-end"
| "right-start" | "right-start"
| "right" | "right"
| "top-end" | "top-end"
| "top-start" | "top-start"
| "top"; | "top";
}; };
export type ProgressBarType = { export type ProgressBarType = {