Skip to content
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

Add Inline comment experimental flag #60622

Open
wants to merge 59 commits into
base: trunk
Choose a base branch
from

Conversation

poojabhimani12
Copy link

@poojabhimani12 poojabhimani12 commented Apr 10, 2024

What?

Introducing the "Block Comment" experiment, with added functionality accessible via this feature flag which when enabled, allows users to add comments to the selected block by clicking on "comment" icon in the toolbar dropdown.

Screenshot at May 14 12-01-47

Why?

#59445

How?

Testing Instructions

  1. Enable the Block Comment experiment
  2. Insert any block
  3. Click on More dropdown from the block toolbar
  4. Click the comment icon in the toolbar and add comment.

Screenshots or screencast

Screenshot at May 14 12-11-59 Screenshot at May 14 12-13-15
demo.webm

Copy link

github-actions bot commented Apr 10, 2024

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @akashdhawade1991, @juhibhatt19, @MD-sunilprajapati.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: akashdhawade1991, juhibhatt19, MD-sunilprajapati.

Co-authored-by: poojabhimani12 <poojabhimani@git.wordpress.org>
Co-authored-by: ingeniumed <ingeniumed@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: annezazu <annezazu@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Apr 10, 2024
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @poojabhimani12! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@poojabhimani12 poojabhimani12 marked this pull request as draft April 10, 2024 06:20
@poojabhimani12 poojabhimani12 marked this pull request as ready for review May 16, 2024 04:49
@cbravobernal cbravobernal added the [Type] Experimental Experimental feature or API. label May 16, 2024
@ingeniumed
Copy link
Contributor

The following is a summary of the discussion that was had with @ellatrix, that's being posted by me for posterity.

In order to be able to test this feature end to end, this PR would need to be updated to add the ability to save comments as well. As a result, the following will need to be be done as the next steps:

  • Update the PR with the data model proposed here so that it actually persists everything. That way, you can see it working end to end.
  • Once this PR is merged in, keep an eye on the feature to see what sort of feedback is coming. Make any changes relevant to the feedback.
  • After sometime, put up a PR to drop the experimental flag so that it can ship in the next WP release - ideally 6.7

if ( contentRef.current ) {
updateBlockAttributes( clientId, {
className: `block-editor-collab__${ threadId }`,
} );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't think we should be modifying blocks attributes to add a border? These attributes will be saved and shown on the front-end. Not sure what this border is until I can test the functionality.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of now, we have implemented commenting functionality at the block level and are adding a custom class with a comment ID to block attributes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but we really shouldn't be setting block attributes to add a class. This should be done another way, maybe with the editor.BlockListBlock filter or a hooks similar to these.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

editor.BlockListBlock may be more straightforward to use for now, with that you can directly filter the block props and also the class name.

@poojabhimani12
Copy link
Author

@ellatrix - We have addressed all your feedback, and the task is now ready for re-review.

@ingeniumed ingeniumed requested a review from ellatrix July 3, 2024 06:20
@@ -0,0 +1,43 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should move within the experimental folder, otherwise it will be backported to core.

@ellatrix
Copy link
Member

ellatrix commented Jul 18, 2024

I got a warning when adding a comment:

image

The inline comment popover seems to move all the time with selection, I think it should be anchored. Additionally, it doesn't disappear when typing. What do you think about moving the comments to the sidebar instead?

inline-comment-placement

It looks like, when I make an uncollapsed selection, the comment just disappears after save + reload.

second-block-comment

I also can't seem to comment on any block that doesn't, have rich text. Fundamentally, it feels like the UI shouldn't be added as a rich text control, but rather as a block control (since commenting is all block-level)?

I now see that there is a sidebar, but I can't interact with the comments. It would be cool if the sidebar also had a button tho comment on the currently selected block.

There's some displacement happening sometimes when I add a comment.

displacement

It looks like I can comment on templates in the Site Editor, but the comments disappear (though the yellow line is still there). I'm guessing saving meta fails for templates. Maybe we should disable the feature for templates.

Seems like a great start. The only more fundamental issues I'd love to see addressed it moving things from rich text controls to block level controls, if we start with commenting at the block level, and where to render the comments. If we try to do something like Google Docs, the sidebar seems more appropriate. Maybe from within the sidebar we could position comments next to blocks when a comment is selected.

const { threads } = useSelect( ( select ) => {
const meta = select( editorStore ).getEditedPostAttribute( 'meta' );
return {
threads: meta?.collab ? JSON.parse( meta.collab ) : false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will return a new object on every select call, which will cause a re-render for every change to the editor store. JSON should be parsed on render instead, perhaps memoized.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also maybe we can use useEntityProp here too?

}
{ Object.keys( threads ).length > 0 &&
Object.values( threads )
.reverse()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does reverse do here? Should they be started by date, and grouped by block position?

"@wordpress/data": "file:../data",
"@wordpress/date": "file:../date",
"@wordpress/editor": "file:../editor",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be adding all these dependencies to this package. But this should be resolved if we move away from adding this control as a format.

@poojabhimani12
Copy link
Author

I also can't seem to comment on any block that doesn't, have rich text. Fundamentally, it feels like the UI shouldn't be added as a rich text control, but rather as a block control (since commenting is all block-level)?

Right now, we've just started with text-level blocks as per jasmussen's comments. We are planning to submit inline commenting and block-level commenting for all blocks soon.

@poojabhimani12
Copy link
Author

Seems like a great start. The only more fundamental issues I'd love to see addressed it moving things from rich text controls to block level controls, if we start with commenting at the block level, and where to render the comments. If we try to do something like Google Docs, the sidebar seems more appropriate. Maybe from within the sidebar we could position comments next to blocks when a comment is selected.

Could you let us know if this design will work for the sidebar comment board?

gutenberg-commenting

@ellatrix
Copy link
Member

Could you let us know if this design will work for the sidebar comment board?

Tbh, I don't see how it could work without being in the sidebar. We can't make space in the canvas like that because styles are dictated by themes. When comments are rendered in the sidebar, they can still be positioned slightly outside the sidebar, horizontally in line with the text, and the lines of the sidebar could be blurred if that's how you'd like to design it.

@annezazu
Copy link
Contributor

@jasmussen tagging you in for some design questions and feedback here ✨ around placement of comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Experimental Experimental feature or API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants