Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Can not correctly split summary of descriptions #24900

Open
xyy94813 opened this issue Nov 19, 2023 · 3 comments
Open

[Bug]: Can not correctly split summary of descriptions #24900

xyy94813 opened this issue Nov 19, 2023 · 3 comments

Comments

@xyy94813
Copy link
Contributor

Describe the bug

Can not correctly split summary of descriptions in table, when summary has special syntax.

To Reproduce

This case will working wrong.

const meta: Meta<typeof MyComp> = {
  title: 'MyComp',
  component: MyComp,
  args: {
  },
  argTypes: {
    offset: {
      description: 'description',
      type: { required: false, name: 'array', value: { name: 'number' } },
      table: {
        type: { summary: 'Array<number> | [number, number]' },
      },
      control: 'object',
    },
  },
};

Got: Array<number> | [number, number]

This case will working well.

const meta: Meta<typeof MyComp> = {
  title: 'MyComp',
  component: MyComp,
  args: {
  },
  argTypes: {
    offset: {
      description: 'description',
      type: { required: false, name: 'array', value: { name: 'number' } },
      table: {
        type: { summary: 'NumberArrary | NumberArrayLike' },
      },
      control: 'object',
    },
  },
};

Got: NumberArrary NumberArrayLike

System

System:
    OS: macOS 13.6.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.20.2 - ~/.nvm/versions/node/v16.20.2/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 8.19.4 - ~/.nvm/versions/node/v16.20.2/bin/npm <----- active
  Browsers:
    Chrome: 119.0.6045.159
    Safari: 16.6
  npmPackages:
    @storybook/addon-actions: ^7.5.3 => 7.5.3 
    @storybook/addon-essentials: ^7.5.3 => 7.5.3 
    @storybook/react: ^7.5.3 => 7.5.3 
    @storybook/react-vite: ^7.5.3 => 7.5.3 
    @storybook/storybook-deployer: ^2.8.16 => 2.8.16 
    eslint-plugin-storybook: ^0.6.15 => 0.6.15 
    storybook: ^7.5.3 => 7.5.3

Additional context

None

@xyy94813
Copy link
Contributor Author

xyy94813 commented Nov 21, 2023

if (detail == null) {
const cannotBeSafelySplitted = /[(){}[\]<>]/.test(summaryAsString);
if (cannotBeSafelySplitted) {
return <ArgText text={summaryAsString} />;
}

@xyy94813
Copy link
Contributor Author

Mark #11868, #11840

@xyy94813
Copy link
Contributor Author

Maybe we can support array input for summary.
I think it is better then "type-parser" and current implement.

const meta: Meta<typeof MyComp> = {
  title: 'MyComp',
  component: MyComp,
  args: {
  },
  argTypes: {
    offset: {
      description: 'description',
      type: { required: false, name: 'array', value: { name: 'number' } },
      table: {
        type: { 
        summary: [
          'Array<number>',
          '[number, number]',
          '(instance: SVGSVGElement | null) => void',
         ] 
        },
      },
      control: 'object',
    },
  },
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Discussion
Development

No branches or pull requests

2 participants