bugfix on corner case

This commit is contained in:
lucataglia 2023-05-19 18:56:26 +02:00
parent 1f6d0291ee
commit e664cba9fb
3 changed files with 6 additions and 2 deletions

View File

@ -111,8 +111,9 @@ export default function JSONNestedNode(props: Props) {
nodeTypeIndicator,
shouldExpandNodeInitially,
shouldExpandNode,
styling,
setShouldExpandNode,
setEnableDefaultButton,
styling,
} = props;
const [expanded, setExpanded] = useState<boolean>(
@ -135,8 +136,9 @@ export default function JSONNestedNode(props: Props) {
if (expandable) {
setExpanded(!expanded);
setEnableDefaultButton(true);
setShouldExpandNode(undefined)
}
}, [expandable, expanded, setEnableDefaultButton]);
}, [expandable, expanded, setEnableDefaultButton, setShouldExpandNode]);
const renderedChildren =
expanded || (hideRoot && level === 0)

View File

@ -79,6 +79,7 @@ export function JSONTree({
shouldExpandNodeInitially={shouldExpandNodeInitially}
shouldExpandNode={shouldExpandNode}
setEnableDefaultButton={setEnableDefaultButton}
setShouldExpandNode={setShouldExpandNode}
hideRoot={hideRoot}
getItemString={getItemString}
postprocessValue={postprocessValue}

View File

@ -54,6 +54,7 @@ export interface CommonExternalProps {
collectionLimit: number;
sortObjectKeys: SortObjectKeys;
setEnableDefaultButton: any;
setShouldExpandNode: any;
}
export interface CommonInternalProps extends CommonExternalProps {