Fix Empty Array And Object Not Showing up
Summary: Reported in [the Workplace group](https://fb.workplace.com/groups/flippersupport/permalink/1002324710248187/), the empty array and object in network plugin wasn't shown and left blank. This happened because data component checked for expandability and decided empty object is not expandable. Thus, it uses different path to render components. This diff fixes that by rendering empty array and object as `[]` and `{}` Reviewed By: jknoxville Differential Revision: D24726219 fbshipit-source-id: 9b22e1011c39c363b73f759477f44f08520734a7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
63241427a0
commit
c04b26d2bc
@@ -80,6 +80,11 @@ const ColorPickerDescription = styled.div({
|
|||||||
});
|
});
|
||||||
ColorPickerDescription.displayName = 'DataDescription:ColorPickerDescription';
|
ColorPickerDescription.displayName = 'DataDescription:ColorPickerDescription';
|
||||||
|
|
||||||
|
const EmptyObjectValue = styled.span({
|
||||||
|
fontStyle: 'italic',
|
||||||
|
});
|
||||||
|
EmptyObjectValue.displayName = 'DataDescription:EmptyObjectValue';
|
||||||
|
|
||||||
type DataDescriptionProps = {
|
type DataDescriptionProps = {
|
||||||
path?: Array<string>;
|
path?: Array<string>;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -708,11 +713,14 @@ class DataDescriptionContainer extends PureComponent<{
|
|||||||
case 'null':
|
case 'null':
|
||||||
return <NullValue>null</NullValue>;
|
return <NullValue>null</NullValue>;
|
||||||
|
|
||||||
|
// no description necessary as we'll typically wrap it in [] or {} which
|
||||||
|
// already denotes the type
|
||||||
case 'array':
|
case 'array':
|
||||||
|
return val.length <= 0 ? <EmptyObjectValue>[]</EmptyObjectValue> : null;
|
||||||
case 'object':
|
case 'object':
|
||||||
// no description necessary as we'll typically wrap it in [] or {} which already denotes the
|
return Object.keys(val).length <= 0 ? (
|
||||||
// type
|
<EmptyObjectValue>{'{}'}</EmptyObjectValue>
|
||||||
return null;
|
) : null;
|
||||||
|
|
||||||
case 'function':
|
case 'function':
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user