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

validateDOMNesting Error #12139

Closed
zsteinerjc opened this issue Aug 19, 2020 · 16 comments
Closed

validateDOMNesting Error #12139

zsteinerjc opened this issue Aug 19, 2020 · 16 comments
Assignees
Labels

Comments

@zsteinerjc
Copy link

zsteinerjc commented Aug 19, 2020

Describe the bug
Migrated existing Storybook instance to v6.0.13. Despite being a @story/vue project, get very large React DOM Nesting error that consumes most fo the browser console.

To Reproduce

  1. Run storybook:serve
  2. Open browser console.
  3. View Error

Warning: validateDOMNesting(...): <ul> cannot appear as a descendant of <p>.

Expected behavior
No run time errors.

Screenshots
Screen Shot 2020-08-19 at 10 23 57 AM

Code snippets
It shows up even when all stories are removed from the library.

System:
System:
OS: macOS 10.15.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node
Yarn: 1.22.0 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.16.1/bin/npm
Browsers:
Chrome: 84.0.4147.125
Firefox: 77.0.1
Safari: 13.1.2
npmPackages:
@storybook/addon-a11y: ^6.0.13 => 6.0.13
@storybook/addon-actions: ^6.0.13 => 6.0.13
@storybook/addon-backgrounds: ^6.0.13 => 6.0.13
@storybook/addon-controls: ^6.0.13 => 6.0.13
@storybook/addon-docs: ^6.0.13 => 6.0.13
@storybook/vue: ^6.0.13 => 6.0.13

Additional context
Add any other context about the problem here.

@dgonzalezr
Copy link

I'm getting the same with web components 🤔

  "@storybook/addon-actions": "^6.0.13",
  "@storybook/addon-essentials": "^6.0.13",
  "@storybook/addon-links": "^6.0.13",
  "@storybook/web-components": "^6.0.13",

@shilman
Copy link
Member

shilman commented Aug 20, 2020

Do you have a repro repo you can share?

@basher
Copy link

basher commented Aug 20, 2020

@shilman
Michael, I'm getting validateDOMNesting error with Storybook composition, which I'm trying out as a replacement for Storybook preview to to view HTML stories with Parcel bundler.

Parent storybook repo = https://github.com/basher/parcel-boilerplate-storybook-preview
HTML / Parcel storybook repo = https://github.com/basher/parcel-boilerplate-storybook

My validateDOMNesting is different:

storybook-composition-js-error

Additionally, in the sidebar menu, my HTML Storybook stories are not showing due to this JSON.parse error:

json-parse-error

@shilman
Copy link
Member

shilman commented Aug 20, 2020

cc @ndelangen

@ndelangen
Copy link
Member

#12139 (comment)
should be a relatively easy fix i think, the html structure seems incorrect.

It's likely to be found here:

export const ErrorBlock: FunctionComponent<{ error: Error }> = ({ error }) => (
<Contained>
<Spaced>
<Text>
Oh no! Something went wrong loading this Storybook.
<br />
<WithTooltip
trigger="click"
closeOnClick={false}
tooltip={
<ErrorDisplay>
<ErrorFormatter error={error} />
</ErrorDisplay>
}
>
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<Link isButton>
View error <Icons icon="arrowdown" />
</Link>
</WithTooltip>{' '}
<Link withArrow href="https://storybook.js.org/docs" cancel={false} target="_blank">
View docs
</Link>
</Text>
</Spaced>
</Contained>
);

@ndelangen
Copy link
Member

@Bashar would you be interested in opening a PR to fix that?

@ndelangen
Copy link
Member

regarding the JSON parse error.. I think what might be happening is that stories.json is resolved, but not valid json?

@basher
Copy link

basher commented Aug 24, 2020

@basher would you be interested in opening a PR to fix that?

I'm confused?
Are you saying that the JS error in the console is caused by the Oh no, smething went wrong... message in the sidebar?

I wouldn't have a clue how to fix this.

@basher
Copy link

basher commented Aug 24, 2020

regarding the JSON parse error.. I think what might be happening is that stories.json is resolved, but not valid json?

Here's the JSON response, for the story that should be loaded from my HTML Storybook:

json-response

@ndelangen
Copy link
Member

Here's the JSON response, for the story that should be loaded from my HTML Storybook:

That is not valid JSON, that's HTML..

if vercel can't serve the file, it should respond with a 404.

@ndelangen
Copy link
Member

Are you saying that the JS error in the console is caused by the Oh no, smething went wrong... message in the sidebar?

Yes, pretty sure that's the cause.

@basher
Copy link

basher commented Aug 25, 2020

That is not valid JSON, that's HTML..

if vercel can't serve the file, it should respond with a 404.

Yes, it's HTML. But surely it's Storybook (composition) that's making the request for stories.json, not Parcel? 😕

We appear to be going round in circles here... and I'm concerned the original bug has been possibly hijacked by my specific issue, which on the face of it looks the same (i.e. console errors about invalid DOM nesting, but actually may not be.

All I want to do is find the correct way to view HTML stories in Storybook, whose CSS/JS/static dependencies are bundled with Parcel 2. In Storybook 5.3, I did that with standalone Storybook preview, but that is not supported in 6, so I thought composition might work.

I've opened a new composition discussion in case anyone else needs a similar setup.

Where do we go from here?

@ndelangen
Copy link
Member

There's 2 issues indeed.

  • the validateDOMNesting Error is definitely a problem in storybook. We're tracking that problem in this issue.
  • the JSON parse error is not a storybook issue.

@basher
Copy link

basher commented Aug 28, 2020

UPDATE:

I just setup a brand new Storybook HTML repo as per default implementation - i.e. no Parcel bundler, no additional dependencies, no customisations whatsoever.

I can view this storybook OK using composition from my parent storybook repo.

I therefore think that I need to re-think my strategy when using Parcel to bundle static UI assets - i.e. CSS, JS, JSON, SVG, etc...

  • I'll setup a repo that just does Parcel static UI asset bundling, then serve these at a specific URL - e.g. localhost:1234.
  • And have a totally separate Storybook HTML repo where my HTML stories reside, and link to the static assets from localhost:1234.

Not ideal, as I would prefer to keep all UI code together (HTML stories + static assets), but I need to move on and get stuff working in Storybook V6 rather than continuing to work in 5.3, and I want to leverage docs & controls too.

@shilman
Copy link
Member

shilman commented Sep 10, 2020

Crikey!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.1.0-alpha.7 containing PR #12298 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Sep 10, 2020
@Bashar
Copy link

Bashar commented Nov 16, 2020

@Bashar would you be interested in opening a PR to fix that?

seems i was mentioned by mistake here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants