-
Notifications
You must be signed in to change notification settings - Fork 431
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(comments): lost comment message while document is reconnecting #5928
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
No changes to documentation |
Component Testing Report Updated Mar 7, 2024 3:07 PM (UTC)
|
This implementation seems fine to me, but can I ask, is there a way to prevent the input from being unmounted at all when the form is set to readonly? |
I'm not sure – I wasn't able to figure it out. Not sure if it possible in this situation, unfortunately. @jtpetty |
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 looks fine as a temporary (and clever!) workaround. Although it feels like a bug that it's not possible to prevent unmounts on readOnly change, making a ticket for it so we can track it.
const handleOnChange = useCallback( | ||
(nextValue: CommentMessage) => { | ||
setValue(nextValue) | ||
messageCache.set(stringPath, nextValue) |
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.
should the key also include the document id? (potentially also projectId+dataset?) to avoid it leaking between documents?
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 see now that you'll get a modal when trying to navigate away, so probably won't be an issue.
Description
This pull request addresses an issue where the comment input unmounts during document reconnection, leading to the loss of the comment being authored. To resolve this, the following solutions have been implemented:
CommentsAuthoringPathContext
. This context is needed because if the "open state" of the comment input is managed locally within the component, the state resets when unmounting. By tracking the user's current authoring path in a context, it ensures the comment input remains open even when the component is re-rendered.What to Review
Ensure that the comment input remains open during form reconnection and that the comment being authored is not lost. While working to debug this issue, I changed the
useConnectionState
hook to toggle between the "connected" and "reconnecting" states using asetTimeout
, as shown below:Notes for release
N/A