diff --git a/lib/components/src/controls/Object.tsx b/lib/components/src/controls/Object.tsx index b168218635a9..5d3b4e98e22f 100644 --- a/lib/components/src/controls/Object.tsx +++ b/lib/components/src/controls/Object.tsx @@ -4,7 +4,7 @@ import React, { ComponentProps, SyntheticEvent, useCallback, useMemo, useState } import { styled, useTheme, Theme } from '@storybook/theming'; // @ts-ignore -import { JsonTree } from './react-editable-json-tree'; +import { JsonTree, getObjectType } from './react-editable-json-tree'; import type { ControlProps, ObjectValue, ObjectConfig } from './types'; import { Form } from '../form'; import { Icons, IconsProps } from '../icon/icon'; @@ -260,7 +260,7 @@ export const ObjectControl: React.FC = ({ name, value, onChange }) return ( - {hasData && ( + {hasData && ['Object', 'Array'].includes(getObjectType(data)) && ( setShowRaw((v) => !v)}> RAW diff --git a/lib/components/src/controls/react-editable-json-tree/index.js b/lib/components/src/controls/react-editable-json-tree/index.js index 7e77c0b2f002..cc55b51b9ba1 100644 --- a/lib/components/src/controls/react-editable-json-tree/index.js +++ b/lib/components/src/controls/react-editable-json-tree/index.js @@ -166,6 +166,7 @@ JsonTree.defaultProps = { }; export { JsonTree }; +export { getObjectType }; export { ADD_DELTA_TYPE }; export { REMOVE_DELTA_TYPE }; export { UPDATE_DELTA_TYPE };