-
Notifications
You must be signed in to change notification settings - Fork 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
Returning null
in a GeneratePreviewURL
function creates type and runtime errors
#2472
Comments
Hi @evelynhathaway - I haven't been able to reproduce this on Definitely agree with you on the preview button, it would be great to either hide or clearly show it as disabled when you return |
@evelynhathaway you were right in that our docs incorrectly indicated that |
feat: supports null preview url #2472
This issue has been automatically locked. |
Link to reproduction
https://payloadcms.com/docs/configuration/collections#preview:~:text=Example%20collection%20with%20preview%20function
To Reproduce
Use the example preview collection function on any collection.
Describe the Bug
TypeScript errors on the return of
null
.The preview button still appears in the Admin UI, and clicking it opens a not found page. It tries to load the URL
null
relative to the current page, which redirects to the generic not found page for the collection.I'd expect that the example function would not have a TypeScript issue and returning
null
would hide the button or at least let the user know that the preview is not available for the current document and its fields.Payload Version
1.6.28
The text was updated successfully, but these errors were encountered: