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

Next/future/image safari border fix make all lazy loaded images bordered #40615

Closed
1 task done
7iomka opened this issue Sep 16, 2022 · 8 comments · Fixed by #43513
Closed
1 task done

Next/future/image safari border fix make all lazy loaded images bordered #40615

7iomka opened this issue Sep 16, 2022 · 8 comments · Fixed by #43513
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).

Comments

@7iomka
Copy link
Contributor

7iomka commented Sep 16, 2022

Verify canary release

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

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 19.6.0: Mon Apr 18 21:50:40 PDT 2022; root:xnu-6153.141.62~1/RELEASE_X86_64
Binaries:
  Node: 16.15.0
  npm: 8.3.0
  Yarn: 3.2.1
  pnpm: 7.1.7
Relevant packages:
  next: 12.3.1-canary.2
  eslint-config-next: 12.2.5
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

Safari 15.5

How are you deploying your application? (if relevant)

No response

Describe the Bug

I used next future image

<Image
    className="w-full h-auto"
    src={item.th}
    alt=""
    width={240}
    height={240}
    placeholder = "blur"
    blurDataURL ="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP88R8AAvUB+VkkrXoAAAAASUVORK5CYII="
    quality={100}
  />

I used hack to fix border on Safari 15+ when images which use loading="lazy" has white border while loading.

@media not all and (min-resolution:.001dpcm) {
  img[loading="lazy"] {
    clip-path: inset(0.5px);
  }
}

Now I see in Safari 15 and ALL images which not have priority have 0.5px transparent (white if light background and black if dark) aka border.

image

Expected Behavior

Expected behavior - css hack needed to be applied only for images in loading state.
Without this css styles lazy loaded images shown correctly
image

Link to reproduction

https://codesandbox.io/p/github/7iomka/effector-react-form-flow/draft/sweet-goldberg?file=%2Fsrc%2Fapp%2Fui-provider%2Fapp-global-styles.tsx&selection=%5B%7B%22endColumn%22%3A11%2C%22endLineNumber%22%3A14%2C%22startColumn%22%3A11%2C%22startLineNumber%22%3A14%7D%5D

To Reproduce

Open Demo in Safari
You can see white border on images loaded in thumbs carousel
image

You can disable fix from styles (src/app/ui-provider/app-global-styles.tsx) to show that this fix caused issue.

Of course, I can use priority, but, if my images is located below the fold, this is not a solution, and it can't be applied to all images.

@7iomka 7iomka added the bug Issue was opened via the bug report template. label Sep 16, 2022
@7iomka
Copy link
Contributor Author

7iomka commented Sep 16, 2022

Also I noticed, that you apply styles after image was loaded

  • for priority image - inset: 0 in styles
  • for rest images - inset: 0 is not present in styles

Why you don't added inset: 0 for all images after it was loaded?
I think this is a key of issue for users that used proposed css fix

@balazsorban44 balazsorban44 added the Image (next/image) Related to Next.js Image Optimization. label Sep 19, 2022
@balazsorban44 balazsorban44 added the Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.). label Oct 12, 2022
@7iomka
Copy link
Contributor Author

7iomka commented Oct 13, 2022

@styfle maybe, but how to figure out now?

@alextes
Copy link

alextes commented Nov 12, 2022

Built a code sandbox with the proposed workaround, still getting the borders in Safari.

Did anyone else find a workaround or able to spot what I did wrong?

https://codesandbox.io/p/sandbox/pensive-babbage-mfmhn2?file=%2Fpages%2Findex.tsx

Screen.Recording.2022-11-11.at.18.23.00.mov

alextes added a commit to ultrasoundmoney/frontend that referenced this issue Nov 12, 2022
On safari the new next image has a white border when loading.
See: vercel/next.js#40615
@styfle styfle linked a pull request Nov 29, 2022 that will close this issue
1 task
@nikkizol
Copy link

Built a code sandbox with the proposed workaround, still getting the borders in Safari.

Did anyone else find a workaround or able to spot what I did wrong?

https://codesandbox.io/p/sandbox/pensive-babbage-mfmhn2?file=%2Fpages%2Findex.tsx

Screen.Recording.2022-11-11.at.18.23.00.mov

Did you find a solution?

@alextes
Copy link

alextes commented Nov 30, 2022

@nandorojo
Copy link

I see the same border issue on Chrome for iOS for what it's worth.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. Image (next/image) Related to Next.js Image Optimization. Upstream Related to using Next.js with a third-party dependency. (e.g., React, UI/icon libraries, etc.).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants