You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am building a Storybook Addon where I add content to a new Tab called Source.
The bug is that the content of the Source tab show up on the Canvas and Docs Tabs.
It only happens with content added after calling an API in a useEffect function.
In the demo you can see that the Open in Github button only appears in the Source Tab as expected but the File tree that is rendered after the api is called, blocks the Canvas and Docs tabs content.
import{addons,types}from'@storybook/addons'importSourceTabfrom'../SourceTab'constADDON_ID='myaddon_source'constPANEL_ID=`${ADDON_ID}/source`addons.register(ADDON_ID,()=>{addons.add(PANEL_ID,{type: types.TAB,title: 'Source',//👇 Checks the current route for the storyroute: ({ storyId, refId })=>refId ? `/mytab/${refId}_${storyId}` : `/mytab/${storyId}`,//👇 Shows the Tab UI element in mytab view modematch: ({ viewMode })=>{returnviewMode==='mytab'},render: ()=><SourceTab/>,})})
SourceTab.js
importgetGithubFilesfrom'../../../../src/data/github/getGithubFiles'importFileTreefrom'../../../../src/dataDisplay/FileTree'import*asSfrom'./styles'exportdefaultfunctionSourceTab(){const[storyFiles,setStoryFiles]=useState([])constfetchStorySource=async()=>{constgithubFolderUrl='lib/src/dataDisplay/Avatar'constfiles=awaitgetGithubFiles({owner: 'jeremytenjo',repo: 'tenjo-apps',path: githubFolderUrl,})setStoryFiles(files)}useEffect(()=>{fetchStorySource()},[])return(<S.Wrapper><ahref='https://github.com/jeremytenjo/tenjo-apps/tree/master/lib/src/dataDisplay/Avatar'target='_blank'rel='noreferrer'>
Open in Github
</a><FileTree>{storyFiles.map((file)=>(<Fragmentkey={file.sha}>{file.type==='file'&&<FileTree.Filename={file.name}/>}{file.type==='dir'&&<FileTree.Foldername={file.name}/>}</Fragment>))}</FileTree></S.Wrapper>)}
Help is much appreciated. Thanks!
The text was updated successfully, but these errors were encountered:
jeremytenjo
changed the title
Creating a custom Addon error - Added panel's content blocks the Canvas and Docs tabs.
Creating a custom Addon bug - Added panel's content blocks the Canvas and Docs tabs.
May 20, 2021
jeremytenjo
changed the title
Creating a custom Addon bug - Added panel's content blocks the Canvas and Docs tabs.
Creating a custom Addon bug - Added panel content blocks the Canvas and Docs tabs.
May 21, 2021
Describe the bug
I am building a Storybook Addon where I add content to a new Tab called Source.
The bug is that the content of the Source tab show up on the Canvas and Docs Tabs.
It only happens with content added after calling an API in a useEffect function.
In the demo you can see that the
Open in Github
button only appears in the Source Tab as expected but the File tree that is rendered after the api is called, blocks the Canvas and Docs tabs content.SourceTab.js
Help is much appreciated. Thanks!
The text was updated successfully, but these errors were encountered: