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

ImageInput does not show image previews (it has been broken since v4.2.7) #8429

Closed
magicxor opened this issue Nov 24, 2022 · 4 comments
Closed

Comments

@magicxor
Copy link

What you were expecting:
When you pick new pictures from your file system, ImageInput shows them as previews.

What happened instead:
When you pick new pictures from your file system, ImageInput does not show them.

Steps to reproduce:

  1. Launch this CodeSandbox or the code from this repo.

  2. Try to upload some pictures to the "Avatars (current)" field.

  3. Try to upload some pictures to the "Avatars (old)" field (which uses the ImageInput from react-admin v4.2.6-).

firefox_kWIYSbfSD8

Related code:

                <ImageInput label="Avatars (current)" source="avatars1" multiple>
                    <ImageField source="url"/>
                </ImageInput>

CodeSandbox or the code from this repo.

Other information:
see:
#7877
#8052

Workaround:
Use the old version of ImageInput (https://github.com/magicxor/react-admin-repro-ImageInput-bug/tree/master/src/StableInputs)

Environment

  • React-admin version: ^4.5.1
  • Last version that did not exhibit the issue (if applicable): v4.2.6
  • React version: ^18.2.0
  • Browser: Chrome 107.0.5304.107 (Official Build) (64-bit) and Firefox 107.0 (64-bit)
  • Stack trace (in case of a JS error):
@WiXSL WiXSL added the bug label Nov 24, 2022
@WiXSL
Copy link
Contributor

WiXSL commented Nov 24, 2022

Reproduced!
Thanks for the report

Try changing the ImageField source prop to `src', that should make it work for now

@fzaninotto
Copy link
Member

ì don't understand this bug.The doc says that the preview component should use src as source (even for 4.2). Your example uses url as source, which is incorrect.

I take it that it may have worked in the past, but this wasn't the documented usage.

Or was the ability to use something else than src documented somewhere?

@magicxor
Copy link
Author

magicxor commented Nov 28, 2022

ì don't understand this bug.The doc says that the preview component should use src as source (even for 4.2). Your example uses url as source, which is incorrect.

"src" is just the name of the property:

image

image

It can be any other valid name.

But I agree, there is ambiguity between the documentation text (The input value must be an object or an array of objects with a title and a src property, e.g.:) and code samples

I mean, why source and title attributes do exist, if they have no effect at all?

@fzaninotto
Copy link
Member

I don't thinks the doc is ambiguous:

The input value must be an object or an array of objects with a title and a src property

Means you cannot put the source in another prop.

If you have a better idea for how to document it, please open a PR! But as for this issue, I'll close it as it's not a bug.

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

No branches or pull requests

3 participants