fix: list preview

This commit is contained in:
Daniel Lautzenheiser 2023-07-14 09:13:00 -04:00
parent cc9b35c669
commit fc3761ab19
2 changed files with 6 additions and 3 deletions

View File

@ -73,7 +73,6 @@ const CollectionControls = ({
sm:w-auto sm:w-auto
sm:justify-normal sm:justify-normal
lg:gap-2 lg:gap-2
flex-[1_0_0%]
" "
> >
<ViewStyleControl viewStyle={viewStyle} onChangeViewStyle={onChangeViewStyle} /> <ViewStyleControl viewStyle={viewStyle} onChangeViewStyle={onChangeViewStyle} />

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { isNotNullish } from '@staticcms/core/lib/util/null.util'; import { isNullish } from '@staticcms/core/lib/util/null.util';
import type { ListField, ValueOrNestedValue, WidgetPreviewProps } from '@staticcms/core/interface'; import type { ListField, ValueOrNestedValue, WidgetPreviewProps } from '@staticcms/core/interface';
import type { FC, ReactNode } from 'react'; import type { FC, ReactNode } from 'react';
@ -8,6 +8,10 @@ import type { FC, ReactNode } from 'react';
function renderNestedList( function renderNestedList(
value: ValueOrNestedValue[] | ValueOrNestedValue | null | undefined, value: ValueOrNestedValue[] | ValueOrNestedValue | null | undefined,
): ReactNode { ): ReactNode {
if (isNullish(value)) {
return null;
}
if (Array.isArray(value)) { if (Array.isArray(value)) {
return ( return (
<ul style={{ marginTop: 0 }}> <ul style={{ marginTop: 0 }}>
@ -18,7 +22,7 @@ function renderNestedList(
); );
} }
if (isNotNullish(value) && typeof value === 'object') { if (typeof value === 'object') {
if (value instanceof Date) { if (value instanceof Date) {
return value.toISOString(); return value.toISOString();
} }