Not quite sure if it a bug but for me, it seems like that it should render the title.
Looking at this line it does not render the menu at all if there is no icon
https://github.com/storybookjs/storybook/blob/477f990494f804a25a71f4f1b69b32c86b6501da/addons/contexts/src/manager/components/ToolBarControl.tsx#L50
To Reproduce
Context configuration:
export default [
{
title: 'Themes', // an unique name of a contextual environment
components: [ // an array of components that is going to be injected to wrap stories
/* Styled-components ThemeProvider, */
/* Material-ui ThemeProvider, */
({children, theme}) => {
return (<ThemeProvider theme={theme}>{children}</ThemeProvider>)
}
],
params: getThemes().map((theme) =>({
name: theme, props: { theme}
})),
options: {
deep: true, // pass the `props` deeply into all wrapping components
disable: false, // disable this contextual environment completely
cancelable: false, // allow this contextual environment to be opt-out optionally in toolbar
}
}
]
Expected behavior
Since its optional https://github.com/storybookjs/storybook/tree/next/addons/contexts#icon--string.
I would have expected that it will render the title instead of the icon.
@jakubikan, I think you are right. For the context have more than 2 sets of params, it does not make sense to hide the selection menu if no icon is given. Although the implementation implies user can "turn it on" in the story-level later, but it seems not useful and not intuitive? Fallback to title seems reasonable to me now.
I will wait a couple days in case someone not happy about that. Depends on the view point, I think this could mark as a bug since it does a bit strange although the doc says you have to provide the icon name.
I'd like to "fix" this behaviour during the next weekend, or @jakubikan may interested to submit your first PR to storybook, I believe the code should be explanatory by itself and straightforward to what you proposed to be changed. 馃槈
Hey @leoyli,
thanks for the response.
I will try to implement this today.
Lets see how it goes 馃槃
Ta-da!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-alpha.29 containing PR #7078 that references this issue. Upgrade today to try it out!
You can find this prerelease on the @debug NPM tag.
Closing this issue. Please re-open if you think there's still more to do.
Most helpful comment
Ta-da!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-alpha.29 containing PR #7078 that references this issue. Upgrade today to try it out!
You can find this prerelease on the
@debugNPM tag.Closing this issue. Please re-open if you think there's still more to do.