-
Notifications
You must be signed in to change notification settings - Fork 4.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
Inline Commenting: Avoid querying comments on editor load #66670
Conversation
defaultAvatar: __experimentalDiscussionSettings?.avatarURL, | ||
clientId: selectedBlock?.clientId, | ||
blockCommentId: selectedBlock?.attributes?.blockCommentId, | ||
showAddCommentBoard: showCommentBoard, |
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.
Not sure why this prop was passed around in mapSelect
. It shouldn't be required.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
}; | ||
}, [] ); | ||
|
||
// Get the dispatch functions to save the comment and update the block attributes. | ||
const { getSelectedBlockClientId } = useSelect( blockEditorStore ); |
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.
The clientId
is now only used in event callback; we can use the static getter.
@@ -98,7 +76,7 @@ export default function CollabSidebar() { | |||
const compare = {}; | |||
const result = []; | |||
|
|||
const filteredComments = threads.filter( | |||
const filteredComments = ( threads ?? [] ).filter( |
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.
A suggestion from previous refactoring - #66592 (comment).
const AddCommentComponent = blockCommentId | ||
? AddCommentToolbarButton | ||
: AddCommentButton; |
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.
Personal nit and simplification 😅
<PluginSidebar | ||
identifier={ collabSidebarName } | ||
// translators: Comments sidebar title | ||
title={ __( 'Comments' ) } | ||
icon={ commentIcon } | ||
> | ||
<div className="editor-collab-sidebar-panel"> | ||
<AddComment | ||
threads={ resultComments } |
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 value was never used, so I've removed it above.
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, haven't tested though. Should be fine if comments/replies can be added.
Size Change: -11 B (0%) Total Size: 1.81 MB
ℹ️ View Unchanged
|
Flaky tests detected in fc2487b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11627378030
|
To consider: unresolved comments should still be displayed on load not just when toggling the sidebar view. |
@mtias that probably should be part of larger refactoring. But even based on the latest mockups, all comments seem to be contained in the sidebar. |
Yeah, I think those mockups are missing the main use case |
I'm going to merge this. Optimizations in this PR don't change the way block comments are rendered. |
…66670) Co-authored-by: Mamaduka <[email protected]> Co-authored-by: ellatrix <[email protected]> Co-authored-by: mtias <[email protected]>
What?
I've updated the collab sidebar to only load comments when it's displayed instead of fetching them when opening the editor. Previously, a query was also made even when the experiment was disabled.
Why?
Unnecessary queries can negatively affect the editor's performance.
How?
Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshot