Skip to content

Commit 1b70894

Browse files
committed
fix: default shouldExpandNodeInitially to false for collapsed nodes. #59
1 parent 74804a5 commit 1b70894

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

core/src/comps/KeyValues.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const KeyValues = <T extends object>(props: KeyValuesProps<T>) => {
2626
typeof collapsed === 'boolean' ? collapsed : typeof collapsed === 'number' ? level > collapsed : false;
2727
const isExpanded = expands[expandKey] ?? defaultExpanded;
2828
const shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, { value, keys, level });
29-
if (expands[expandKey] === undefined && !shouldExpand) {
29+
if (expands[expandKey] === undefined && shouldExpandNodeInitially && !shouldExpand) {
3030
return null;
3131
}
3232
if (isExpanded) {

core/src/comps/NestedClose.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const NestedClose = <T extends object>(props: NestedCloseProps<T>) => {
2020
const isExpanded = expands[expandKey] ?? defaultExpanded;
2121
const len = Object.keys(value!).length;
2222
const shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, { value, keys, level });
23-
if (expands[expandKey] === undefined && !shouldExpand) {
23+
if (expands[expandKey] === undefined && shouldExpandNodeInitially && !shouldExpand) {
2424
return null;
2525
}
2626
if (isExpanded || len === 0) {

core/src/comps/NestedOpen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const NestedOpen = <T extends object>(props: NestedOpenProps<T>) => {
2727
const isObject = typeof value === 'object';
2828
let isExpanded = expands[expandKey] ?? defaultExpanded;
2929
const shouldExpand = shouldExpandNodeInitially && shouldExpandNodeInitially(!isExpanded, { value, keys, level });
30-
if (expands[expandKey] === undefined && !shouldExpand) {
30+
if (expands[expandKey] === undefined && shouldExpandNodeInitially && !shouldExpand) {
3131
isExpanded = !shouldExpand;
3232
}
3333
const click = () => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
"lint-staged": "^15.0.0",
3333
"lerna": "^8.0.0",
3434
"prettier": "^3.0.0",
35-
"tsbb": "^4.5.1"
35+
"tsbb": "^4.5.5"
3636
}
3737
}

0 commit comments

Comments
 (0)