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

<FileInput> doesn't work #4029

Closed
ss-dev opened this issue Nov 22, 2019 · 6 comments
Closed

<FileInput> doesn't work #4029

ss-dev opened this issue Nov 22, 2019 · 6 comments
Assignees
Labels

Comments

@ss-dev
Copy link

ss-dev commented Nov 22, 2019

I have a simple form for editing emails:

<Edit {...props} undoable={false}>
    <SimpleForm>
        <TextField source="id" />
        <TextInput source="name" />
        <TextInput source="subject" />
        <RichTextInput source="body" />
        <FileInput source="attachment">
            <FileField source="src" title="title" />
        </FileInput>
    </SimpleForm>
</Edit>

When I save it without any files, it's okay.
But if I add some file, and click "Save" button, I have next error:

sanitizeEmptyValues.js:16 Uncaught TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at sanitizeEmptyValues (sanitizeEmptyValues.js:16)
    at sanitizeEmptyValues.js:18
    at Array.reduce (<anonymous>)
    at sanitizeEmptyValues (sanitizeEmptyValues.js:16)
    at submit (SimpleForm.js:60)
    at Object.submit (final-form.es.js:1291)
    at handleSubmit (react-final-form.es.js:263)
    at SimpleForm.js:118
    at handleMouseDown (SaveButton.js:115)
    at ButtonBase.js:145
    at useEventCallback.js:15
    at HTMLUnknownElement.callCallback (react-dom.development.js:337)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:386)
    at invokeGuardedCallback (react-dom.development.js:439)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:454)
    at executeDispatch (react-dom.development.js:585)
    at executeDispatchesInOrder (react-dom.development.js:610)
    at executeDispatchesAndRelease (react-dom.development.js:713)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:722)
    at forEachAccumulated (react-dom.development.js:694)
    at runEventsInBatch (react-dom.development.js:739)
    at runExtractedPluginEventsInBatch (react-dom.development.js:881)
    at handleTopLevel (react-dom.development.js:5832)
    at batchedEventUpdates$1 (react-dom.development.js:24387)
    at batchedEventUpdates (react-dom.development.js:1414)
    at dispatchEventForPluginEventSystem (react-dom.development.js:5928)
    at attemptToDispatchEvent (react-dom.development.js:6045)
    at dispatchEvent (react-dom.development.js:5948)
    at unstable_runWithPriority (scheduler.development.js:704)
    at runWithPriority$2 (react-dom.development.js:12232)
    at discreteUpdates$1 (react-dom.development.js:24404)
    at discreteUpdates (react-dom.development.js:1439)
    at dispatchDiscreteEvent (react-dom.development.js:5915)

dependencies:

    "@material-ui/core": "^4.6.1",
    "body-parser": "^1.19.0",
    "connected-react-router": "^6.6.0",
    "create-react-app": "^3.2.0",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "express-basic-auth": "^1.2.0",
    "express-handlebars": "^3.1.0",
    "express-interceptor": "^1.2.0",
    "material-ui": "^0.20.2",
    "prop-types": "^15.7.2",
    "ra-core": "^3.0.0",
    "ra-data-json-server": "^3.0.0",
    "ra-input-rich-text": "^3.0.0",
    "ra-ui-materialui": "^3.0.0",
    "react": "^16.12.0",
    "react-admin": "^3.0.0",
    "react-dom": "^16.12.0",
    "react-final-form": "^6.3.3",
    "react-scripts": "^3.2.0",
    "react-split-pane": "^0.1.89"
@fzaninotto
Copy link
Member

I can't reproduce the issue on the simple example. Can you please provide a CodeSandbox demonstrating the issue?

@ss-dev
Copy link
Author

ss-dev commented Nov 26, 2019

@fzaninotto https://codesandbox.io/s/react-admin-file-upload-issue-m7v4o

Just try to edit an existing record. Add some attachment and click "Save".

@bicstone
Copy link
Contributor

bicstone commented Nov 27, 2019

it might be related to #4035 and #3087 (comment)

works below:
https://codesandbox.io/s/react-admin-file-upload-issue-qcrxn?hidenavigation=1&module=%2Fsrc%2Fdata.js

data.js:9

- attachment: null
+ attachment: ""

@ss-dev
Copy link
Author

ss-dev commented Nov 28, 2019

@bicstone yeah, it works. thanks!

@fzaninotto
Copy link
Member

Reproduced and confirmed, thanks.

@fzaninotto
Copy link
Member

Fixed by #4082

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

No branches or pull requests

3 participants