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

Image Placeholder isn't displayed while image is loading #4375

Closed
AdleyJulian opened this issue Jun 7, 2023 · 4 comments
Closed

Image Placeholder isn't displayed while image is loading #4375

AdleyJulian opened this issue Jun 7, 2023 · 4 comments

Comments

@AdleyJulian
Copy link

What package has an issue

@mantine/core

Describe the bug

The component prop description for withPlaceholder says "Enable placeholder when image is loading and when image fails to load", however the current behavior is only when the image fails to load.

What version of @mantine/hooks page do you have in package.json?

"^6.0.10"

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

None

Are you willing to participate in fixing this issue and create a pull request with the fix

None

Possible fix

Add a loading state.

const [error, setError] = useState(!src);
const [loaded, setLoaded] = useState(false);
const isPlaceholder = withPlaceholder && (error || !loaded);

Update loaded state.

onError={(event) => {
setError(true);
typeof imageProps?.onError === 'function' && imageProps.onError(event);
}}
onLoad={() => setLoaded(true)}

@rtivital
Copy link
Member

We previously had this logic with the loading state, there was a race condition that prevented placeholders from switching to image with ssr frameworks, see #629. It is not planned to change this logic.

@rtivital rtivital closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2023
@fabiendeborde
Copy link

@rtivital
Hello, I know this issue is closed and there won't be a fix on this placeholder logic, but could you please reflect this stance in the documentation ?
As @AdleyJulian stated, the documentation indicate that the placeholder will show during image loading while it is not.

It is not really a big deal, but I just lost a few minutes trying to debug why the placeholder wasn't working until I got here.

@rtivital
Copy link
Member

Documentation is up to date – https://mantine.dev/core/image/

@fabiendeborde
Copy link

Oh, sorry I am still using v6, I didn't check v7 yet...
Thanks for you quick answer!

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

No branches or pull requests

3 participants