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

View File

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

View File

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