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.

ResolveInput Hook for File field not saving data correctly

See original GitHub issue

Bug report

Describe the bug

When using the File field type on a list along with the resolveInput hook, data isn’t being saved correctly, resulting in some fields being blank in the admin ui.

To Reproduce

  1. Create a list that uses the File field type (using local file in my case)
  2. Add a resolveInput hook to the field as follows:
hooks: {
         resolveInput: ({ resolvedData, }) => resolvedData
}
  1. Upload a file/item to that list (I tested with an mp3 file)
  2. See a blank field listed for the file name

Expected behaviour

The file field should allow the resolveInput hook to manipulate (or simply return in this case) the resolvedData object and save the file correctly and display the file name.

Screenshots

Screen Shot 2020-03-09 at 9 30 58 PM

System information

  • OS: macOS
  • Browser: Chrome

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Falbanacommented, Mar 10, 2020

Hi, I encoutered the same problem, turns out that if you use the resolveInput hook inside the file field (not after the fields), you have to return only the input file and not resolvedData (resolvedData contains all the data, not only the file) file: { ... hooks: { resolveInput: async ({ resolvedData }) => { var fileInput = resolvedData.file; ... return fileInput; }}}

Hope it helped

0reactions
bladeycommented, Apr 8, 2021

Keystone 5 has officially moved into active maintenance mode as we push towards the next major new version Keystone Next, you can find out more information about this transition here.

In an effort to sustain the project going forward, we’re cleaning up and closing old issues such as this one. If you feel this issue is still relevant for Keystone Next, please let us know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML input file selection event not firing upon selecting the ...
Set the value of the input to null on each onclick event. This will reset the input 's value and trigger the onchange...
Read more >
Handling File Fields using React Hook Form - Fullstack.io
In this article, we will learn how to handle file uploads using react-hook-form.
Read more >
Address Validation API Documentation | FedEx Developer Portal
The Address Validation API is a smart solution to resolve inaccurate contact details and enable faster delivery of packages with precision.
Read more >
wuzzle - npm
For file transpilation, wuzzle provides a webpack based transpiler. ... Hook up webpack based compilation for JS runners.
Read more >
Improve modal management in React with nice-modal-react
In this tutorial, we will explore nice-modal-react, which is a ... It is expected that we will be able to use modals to...
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