Customize Behavior
Custom filtering, sorting and grouping
- Here is the overview on how it works:
- Enable custom actions in the comments sidebar.
- Add Velt Button Wireframe to the sidebar wireframe.
- Handle click events and lifecycle events to apply custom filtering, sorting, and grouping logic.
- Update sidebar data.
- Here are the steps to implement it:
Enable Custom Actions
Using Props:
Using API:
Add Velt Buttons and handle click events
- Learn more about how to setup Velt Button Wireframe.
- Set default state using the
active
prop. - Handle
veltButtonClick
event to implement custom filtering, sorting, and grouping logic. It returns VeltButtonClickEvent.
Handle the button click event:
Handle Sidebar data lifecycle events
-
There are two lifecycle events you need to handle to implement custom filtering, sorting, and grouping logic:
commentSidebarDataInit
: Triggered when comment sidebar data is first loaded. It returns CommentSidebarDataInitEventcommentSidebarDataUpdate
: Triggered when comment sidebar data is updated. It returns CommentSidebarDataUpdateEvent- This event can trigger multiple times when either the comment data or unread comment count changes.
Update sidebar data based on custom logic
-
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.
Navigation
onCommentClick
- 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 |
onCommentNavigationButtonClick
- This event is triggered when the navigation button in the comment dialog in the Sidebar is clicked.
- Use this event to implement custom navigation logic.
enableSidebarUrlNavigation
- 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:
UI
pageMode
- This adds a composer in the sidebar where users can add comments without attaching them to any specific element.
Default: false
embedMode
- 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.
excludeLocationIdsFromSidebar
- Use this to filter out comments from certain locations. These comments will not be displayed in the sidebar.
Using Props:
Using API:
floatingMode
- This makes the sidebar open in an overlay panel over the sidebar button float over the page content.
position
- Change the default direction where the sidebar opens from.
- Options:
left
orright
- Default:
right
openCommentSidebar
currentLocationSuffix
- Adds “(this page)” suffix to the group name when the current location matches the group’s location.
Default: false
filterPanelLayout
- Change the layout of the filter panel in the sidebar.
- Options:
menu
orbottomSheet
Default: bottomSheet
focusedThreadMode
- 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. Learn more about it here.
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.
searchPlaceholder
- Customize the placeholder text shown in the search input of the comments sidebar.
System Filters, Sorting and Grouping
filterConfig
- Customize the available system filters:
location
people
priority
category
status
- You can rename, disable, configure grouping, and multi-select behavior of the filters as needed.
groupConfig
- Enable/disable the option to group comments in the sidebar with the
group config
attribute:
sortData
- 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
setCommentSidebarFilters
- Programmatically set the system filters on the sidebar:
API Methods:
Was this page helpful?