-
Notifications
You must be signed in to change notification settings - Fork 429
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(core): Fix Title in "Untitled was published" toast #7473
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
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.
looks good. left a comment on react conventions but nothing blocking
const event: any = useDocumentOperationEvent(documentId, documentType) | ||
const prevEvent = useRef(event) | ||
const paneRouter = usePaneRouter() | ||
const {t} = useTranslation(structureLocaleNamespace) | ||
|
||
if ( |
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.
this may be more react-esque if it was calculated. e.g.
const title = useMemo(() => {
// If title isn't set from document preview, use the title from the document pane value
if (
!documentTitleInfo.title &&
!titleError &&
!IGNORE_OPS.includes(event?.op) &&
typeof documentPaneValue.title === 'string' &&
event?.type === 'success'
) {
return documentPaneValue.title
}
return documentTitleInfo.title
}, [documentTitleInfo.title, titleError, event, documentPaneValue.title])
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.
👍 Thanks for that suggestion, I was going back and forth on the decision to memoize it.
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.
its not too important to memoize it since the value isn't an object reference and is cheap to calculate but it kinda feels better to useMemo than to have an IIFE e.g. const title = (() => {})()
do the same thing. mutating the variable is the thing to avoid in react renders
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.
Yeah, I like the memo approach better. I went ahead and made that change.
Component Testing Report Updated Sep 6, 2024 7:11 PM (UTC) ✅ All Tests Passed -- expand for details
|
* fix(core): Fix Title in "Untitled was published" toast * PR feedback: refactor to useMemo
Description
This PR fixes a bug where a success message shows "Untitled was published" when publishing (and unpublishing) a document with a title. This is especially prevalent on documents with an
image
field.It adds an additional check for a title in the current document title when the title is not available on the document preview title.
What to review
Ensure that the using the document pane value directly as a last resort for a title is a safe approach.
Testing
title
and then publish the documentNotes for release