Comments Sidebar
Customize Behavior
1. Comment click event
- Listen for click events on comments in the sidebar to trigger actions like navigation.
- The event callback provides access to the clicked comment’s annotation object, which includes
location
andcontext
data. - Use this data to update your app’s state and navigate to the comment’s location.
The event handler receives an object with the following properties:
Property | Type | Description |
---|---|---|
documentId | string | ID of the document containing the comment |
location | Object | Location details of the comment |
targetElementId | string | DOM ID of the element the comment is attached to |
context | Object | Custom context data associated with the comment |
annotation | CommentAnnotation | The full comment annotation object |
2. Custom filtering, sorting and grouping
- Here is the overview on how it works:
- Enable custom actions in the comments sidebar.
- Add action buttons to the sidebar wireframe.
- Implement callback and event handlers to handle custom filtering, sorting, and grouping logic.
- Set custom filtered data in the comments sidebar.
- Here are the steps to implement it:
1
Enable Custom Actions
Using Props:
Using API:
2
Add action buttons to the sidebar wireframe
- Specify an
id
to the action button. This can be used to identify which button was clicked/toggled in the callback or lifecycle events. - There are two types of action buttons available:
toggle
: This button has on and off states. This can be used to enableAND
logic.default
: This button has only one state. This can be used to take action on click eg: sort, filter or group by a field.
3
Set default actions
- Set default custom sorting and filtering options in the comments sidebar.
- When the sidebar is initialized, the default actions will be applied.
- The keys of the object are the IDs of the action buttons you defined in the wireframe.
4
Implement custom filtering, sorting, and grouping logic
-
Handle lifecycle and click events to implement custom filtering, sorting, and grouping logic:
onCommentSidebarActionButtonClick
: Triggered when an action button is clicked.onCommentSidebarInit
: Triggered when the comments sidebar is initialized.onCommentSidebarData
: Triggered when the comments sidebar data is updated.
-
The events/lifecycle methods return a CommentSidebarCustomActionEventData object containing:
actions
: Map of custom action button statesdata
: All unfiltered comment annotationsunreadDataMap
: Map of unread comment counts by annotation IDsystemFilteredData
: Comment annotations filtered by system filters
5
Set custom filtered data
-
Once you have applied your custom filtering, sorting, and grouping logic, create the data an array of CommentSidebarData objects and set it in the comments sidebar.
-
Use the
options
parameter to control if you want to group the comments or not.
3. Add composer to sidebar with Page mode
- This adds a composer in the sidebar where users can add comments without attaching them to any specific element.
Default: false
4. Embed Sidebar in your component
- By default, the sidebar will open up from the right corner of the page.
- With embed mode, you can add the sidebar in your component and it will take up the full width and height of its container.
- When in embed mode, the sidebar will not have the close button. You need to implement your own open and close functionality on the host component.
5. Exclude comments from certain locations
- Use this to filter out comments from certain locations. These comments will not be displayed in the sidebar.
Using Props:
Using API:
6. Floating mode
- This makes the sidebar open in an overlay panel over the sidebar button float over the page content.
7. Change sidebar open position
- Change the default direction where the sidebar opens from.
- Options:
left
orright
- Default:
right
8. Enable/Disable Sidebar URL Navigation
- By default, clicking a comment in the sidebar doesn’t automatically update the page URL where the comment was added.
- Use this to enable automatic URL navigation when clicking comments in the sidebar.
- If your app’s state is more complex, you might need to listen for
onCommentClick
events and implement custom navigation logic.
Default: false
Using Props:
Using API method:
9. Open/close the Comments Sidebar
10. Enable/disable “this page” suffix
- Adds “(this page)” suffix to the group name when the current location matches the group’s location.
Default: false
11. System Filters Customization
- Customize the available system filters:
location
people
priority
category
- You can rename, disable, configure grouping, and multi-select behavior of the filters as needed.
12. System Grouping Customization
- Enable/disable the option to group comments in the sidebar with the
group config
attribute:
13. System Sorting Customization
- Change the default sorting order of Comments in the Sidebar.
- Default:
desc
There are three options for sorting:
asc
- to show comments in ascending order of when they were last updateddesc
- to show comments in descending order of when they were last updatednone
- to show comments in the sequence they were added
14. Apply System Filters Programmatically
- Programmatically set the system filters on the sidebar:
API Methods:
15. Filter panel layout customization
- Change the layout of the filter panel in the sidebar.
- Options:
menu
orbottomSheet
Default: bottomSheet
16. Focused Thread Mode
- In this mode, when you click on a comment in the sidebar, it opens the thread in an expanded view within the sidebar itself.
- Other threads and actions like filters, search etc. are hidden behind a back button.
- Enabling this mode also adds a navigation button in the comment dialog. Clicking it will navigate to the comment and trigger a callback.
- If you had previously used a wireframe for the comment dialog, you will need to add the navigation button wireframe and the focused thread wireframe.
Handling the navigation button click: