-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix custom views setter issue #5586
Conversation
🦋 Changeset detectedLatest commit: ce5e786 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/9e5CGFARun1vk7J4NJoSffFqx4cu |
@@ -93,7 +93,7 @@ export function useAdminMeta(adminMetaHash: string, fieldViews: FieldViews) { | |||
); | |||
} | |||
}); | |||
const views = fieldViews[field.viewsIndex]; | |||
const views = { ...fieldViews[field.viewsIndex] }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not trace why this views
has Field
property as getter only, best way would be to make sure this allows setter, but this is quick fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show an example of how you defined your custom field views? I'd like to try to recreate this so we can get to the root cause of the bug.
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ce5e786:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this is happening because the module exports are special, and we need to turn it into a plain object to overwrite the built-in views with custom ones.
This fix may not be the most elegant solution (cc/ @mitchellhamilton) but verified it works for now.
Glad you picked it up @gautamsi and thanks for the PR! the fix will go out with the release today.
I've added back in an example (otherwise commented out) so this can be more easily tested, and will open a separate PR later with an actual example project demoing and testing this functionality.
found issue when trying to use custom views, it gives this error
Cannot set property Field of #<Object> which has only a getter
I was able to fix this using this change, not sure if this is best way to do this. I could not find any other way.