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.

next/future/image parent position warning

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 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000
Binaries:
  Node: 16.13.1
  npm: 8.1.2
  Yarn: 1.22.17
  pnpm: N/A
Relevant packages:
  next: 12.3.2-canary.0
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Microsoft Edge Version 105.0.1343.42 (Official build) (arm64)

How are you deploying your application? (if relevant)

Not relevant.

Describe the Bug

The issue is a false positive console warning:

Image with src "/_next/static/media/test-image.d677443e.jpg" has "fill" and parent element with invalid "position". Provided "" should be one of absolute,fixed,relative.

This can be observed in repro example where the image has the fill attribute and parent position is relative.

The culprit of this issue seems to be L284 of the following snippet: https://github.com/vercel/next.js/blob/2b9afcfea3ce1f43833da26324b88693f2b11c8c/packages/next/client/future/image.tsx#L283-L293

Window.getComputedStyle returns an empty CSSStyleDeclaration in case the inspected element is not in the DOM tree.

A potential fix for this would be to add an additional check for img.parentElement actually being in the DOM tree on L283.

Expected Behavior

The false positive console warning should not appear.

Link to reproduction

https://github.com/filip-kis-fsc/nextjs-future-image-parent-position-issue

To Reproduce

  1. clone repo
  2. cd project root
  3. yarn
  4. yarn dev
  5. open dev tools console tab
  6. refresh the page
  7. observe the false positive warning in the browser dev tools console

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
laclancecommented, Oct 28, 2022

and this Image with src "/img/logo-dark.png" has either width or height modified, but not the other. If you use CSS to change the size of your image, also include the styles 'width: "auto"' or 'height: "auto"' to maintain the aspect ratio.

    <NoSsr>
      <Image className='select-none' width={width || 194} height={height || 80} src="/img/logo-dark.png" alt="TallOrder" priority />
    </NoSsr>
0reactions
gtonussicommented, Dec 21, 2022

I also have this issue using Chrome, when the parent div is certainly ‘position: relative’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Positioning Image in next js [duplicate] - css - Stack Overflow
I want to make my Image on the most right of the page, I try to modify with position: absolute and right: 0...
Read more >
Fusion Global HR: Parent Position Is Not Available In Request ...
Fusion Global HR: Parent Position Is Not Available In Request Position ... Position is not coming in search results via Responsive UI.
Read more >
Why node setParent will remain the position default?
In some case,i will set the parent position firstly,then create the child node and setParent.But we have the default processing that remain ...
Read more >
2748168 - Parent Position field is editable creating a position
The Parent Position field is editable creating a position in Headcount Planning If you create the position via Position Org Chart, the Parent...
Read more >
Certified Peer Specialist - Parent (CPS-P)
Unfortunately this position has been closed but you can search our 1,674 open jobs ... Qualified candidates must the be parent or legal...
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