question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next13: unwanted div element added inside layout

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103
Binaries:
  Node: 16.17.1
  npm: 8.15.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant packages:
  next: 13.0.0
  eslint-config-next: 13.0.0
  react: 18.2.0
  react-dom: 18.2.0

warn - Latest canary version not detected, detected: “13.0.0”, newest: “13.0.2-canary.0”. Please try the latest canary version (npm install next@canary) to confirm the issue still exists before creating a new issue. Read more - https://nextjs.org/docs/messages/opening-an-issue

What browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

No response

Describe the Bug

I can confirm that for every nested layout that I’ve used, there is a parent div which children is wrapped inside them. I’ve checked my code I don’t return that <div> so I suspect is wrapping children around another div.

Expected Behavior

I expect it to be wrapped inside Fragment(if necessary) because, <div> messes my styles

Link to reproduction

yarn create next-app nextjs-server-components --experimental-app

To Reproduce

Check the default Next.js rendered HTML for path /, there is a <div> around page container which is neither present inside the default layout nor inside the page

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

34reactions
long-lazulicommented, Nov 6, 2022

Hi, While waiting for a proper solution, I wanted to mention that this simple CSS resolve a lot of my issues with these unwanted div.

[data-nextjs-scroll-focus-boundary] {
  display: contents;
}

it will not work for older browsers unfortunately.

3reactions
danieljpgocommented, Dec 13, 2022

It was fixed in the last canary

https://github.com/vercel/next.js/pull/43717

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next.JS Image `layout='fill'` is broken - css - Stack Overflow
js image component, the docs claim that: "When fill, the image will stretch both width and height to the dimensions of the parent...
Read more >
Overflowing content - Learn web development | MDN
Unwanted overflow in web design. Modern layout methods (described in CSS layout) manage overflow. They largely work without assumptions or ...
Read more >
Styling Next.js with Styled JSX
<style jsx> elements should be placed inside the root element of the component. Adding global styles. Most projects need some global styles to ......
Read more >
How to remove specific div element by using JavaScript?
In this article, we will discuss three simple ways to remove a specific 'div' element using plain Javascript. Using parentNode.
Read more >
Content Jumping (and How To Avoid It) | CSS-Tricks
We could measure the size of it here and set min-height: 363px on a placeholder element. This meant that the surrounding layout began...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found