storybook [Bug]:颜色控制会自动弹出,而不会触发控制本身

31moq8wy  于 3个月前  发布在  其他
关注(0)|答案(1)|浏览(24)

描述bug

当访问一个带有颜色控制的故事时,控制将自动打开

重现步骤

  1. 转到 https://634ff0d0ec053b270775979d-vpmrbjlyny.chromatic.com/?path=/story/addons-controls-basics--undefined
  2. 在控件面板中,颜色选择器会自动打开

其他上下文

  • 无响应*
1zmg4dgp

1zmg4dgp1#

要解决颜色控制自动打开的问题,请确保在 ColorControl 组件中默认将 startOpen 属性正确设置为 false。检查 Color.tsx 中的实现并验证 Color.stories.tsx 中的故事。

  1. Color.tsx 中,确保默认将 startOpen 设置为 false:
export const ColorControl: FC<ColorControlProps> = ({
  name,
  value: initialValue,
  onChange,
  onFocus,
  onBlur,
  presetColors,
  startOpen = false, // Ensure this is set to false
  argType,
}) => {
  // ...
};
  1. Color.stories.tsx 中,验证 startOpen 属性除非需要显式指定,否则不会被设置为 true:
export const StartOpen: Story = {
  args: {
    startOpen: true, // Only set to true for this specific story
  },
};

这应该防止颜色选择器在没有指定的情况下自动打开。

参考资料

/code/lib/blocks/src/controls/Color.tsx
/code/lib/blocks/src/controls/Color.stories.tsx
/code/addons/controls/src/manager.tsx

关于 Greptile

此响应为您提供了研究的起点,而不是精确的解决方案。
帮助我们改进!如果这有帮助,请留下一个 👍,如果不相关,请留下一个 👎。

相关问题