[WEB-2348] fix: allow updating comments with just mentions in them#5471
[WEB-2348] fix: allow updating comments with just mentions in them#5471
Conversation
WalkthroughThe changes involve renaming the Changes
Sequence Diagram(s)sequenceDiagram
participant Editor
participant CommentCheck
participant Helper
Editor->>CommentCheck: Check if comment is empty
CommentCheck->>Helper: Call isCommentEmpty(comment)
Helper-->>CommentCheck: Return true/false
CommentCheck-->>Editor: Update editor state based on result
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- space/core/components/editor/lite-text-editor.tsx (2 hunks)
- space/helpers/string.helper.ts (1 hunks)
- web/core/components/editor/lite-text-editor/lite-text-editor.tsx (2 hunks)
- web/core/components/issues/issue-detail/issue-activity/comments/comment-card.tsx (3 hunks)
- web/core/components/issues/issue-detail/issue-activity/comments/comment-create.tsx (2 hunks)
- web/helpers/string.helper.ts (1 hunks)
Additional comments not posted (11)
space/core/components/editor/lite-text-editor.tsx (2)
8-8: Approved import change for clarity.The change from
isEmptyHtmlStringtoisCommentEmptyaligns better with the function's usage in the context of comments, enhancing semantic clarity.
36-36: Approved usage ofisCommentEmpty.Using
isCommentEmptyto determine if the initial value of the editor is empty simplifies the logic and improves maintainability.space/helpers/string.helper.ts (2)
53-55: Approved enhancements toisEmptyHtmlString.The addition of the
allowedHTMLTagsparameter enhances the flexibility and utility of the function, allowing it to handle a customizable set of allowed HTML tags.
60-72: Approved addition ofisCommentEmpty.The new function
isCommentEmptyenhances the module's utility by providing a clear and concise method for validating comment content, aligning well with the PR objectives.web/core/components/issues/issue-detail/issue-activity/comments/comment-create.tsx (2)
11-11: Approved import change for clarity.The change from
isEmptyHtmlStringtoisCommentEmptyaligns better with the function's usage in the context of comments, enhancing semantic clarity.
56-56: Approved usage ofisCommentEmpty.Using
isCommentEmptyto determine if the comment is empty simplifies the logic and improves maintainability.web/core/components/editor/lite-text-editor/lite-text-editor.tsx (2)
12-12: Updated import statement to useisCommentEmpty.The import statement has been correctly updated to reflect the new function name, which is more semantically appropriate for checking if a comment is empty.
62-62: Usage ofisCommentEmptyfor initial value check.The usage of
isCommentEmptyinstead of the previousisEmptyHtmlStringsuggests a more tailored approach to determining if a comment is empty, especially considering the context of mentions and images. This should improve the functionality as described in the PR summary.web/core/components/issues/issue-detail/issue-activity/comments/comment-card.tsx (2)
16-16: Updated import statement to useisCommentEmpty.The import statement has been correctly updated to reflect the new function name, which is more semantically appropriate for checking if a comment is empty.
84-84: Usage ofisCommentEmptyfor determining comment emptiness.The usage of
isCommentEmptyinstead of the previousisEmptyHtmlStringsuggests a more tailored approach to determining if a comment is empty, especially considering the context of mentions and images. This should improve the functionality as described in the PR summary.web/helpers/string.helper.ts (1)
233-235: EnhancedisEmptyHtmlStringand addedisCommentEmpty.The
isEmptyHtmlStringfunction now accepts an additional parameterallowedHTMLTags, which allows for more flexible handling of HTML content. This is a significant improvement for scenarios where specific tags need to be allowed.The new
isCommentEmptyfunction provides a comprehensive check for comment emptiness, considering undefined, empty strings, and specific HTML structures. This function is crucial for the functionality described in the PR, ensuring that comments with only mentions or images are not considered empty.Both functions appear to be implemented correctly and should enhance the module's functionality as intended.
Also applies to: 239-252
There was a problem hiding this comment.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- space/helpers/string.helper.ts (1 hunks)
- web/core/components/issues/issue-modal/draft-issue-layout.tsx (1 hunks)
- web/helpers/string.helper.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- space/helpers/string.helper.ts
Additional comments not posted (2)
web/core/components/issues/issue-modal/draft-issue-layout.tsx (1)
77-77: Approve the change toisEmptyHtmlStringfunction call.The modification to include
["img"]as an argument in theisEmptyHtmlStringfunction call is aligned with the PR's objective. This change ensures that HTML strings containing only images are not considered empty, which is crucial for enabling the submit button in scenarios described in the PR.The code change is approved.
Ensure that other components using
isEmptyHtmlStringare not adversely affected by this change. Consider running a full regression test to verify that the behavior of other features relying on this function remains consistent.web/helpers/string.helper.ts (1)
240-252: Approve the addition ofisCommentEmpty.The new
isCommentEmptyfunction is a valuable addition for robustly checking if a comment is effectively empty. This function considers various conditions, including specific HTML tags, which aligns with the PR's objective to handle comments containing only mentions or images.The code change is approved.
Verify the integration of
isCommentEmptywith the comment handling logic throughout the application to ensure it functions as expected in all scenarios.
| export const isEmptyHtmlString = (htmlString: string, allowedHTMLTags: string[] = []) => { | ||
| // Remove HTML tags using regex | ||
| const cleanText = DOMPurify.sanitize(htmlString, { ALLOWED_TAGS: ["img"] }); | ||
| const cleanText = DOMPurify.sanitize(htmlString, { ALLOWED_TAGS: allowedHTMLTags }); |
There was a problem hiding this comment.
Approve the enhancement to isEmptyHtmlString.
The addition of the allowedHTMLTags parameter enhances the flexibility of the isEmptyHtmlString function, allowing it to be customized for different scenarios. This change supports the PR's objective by enabling the function to consider specific HTML tags as non-empty.
The code change is approved.
Would you like me to help create unit tests for this function to ensure it handles various HTML inputs correctly?
Problem:
While trying to update a comment, the submit button remains disabled if the comment just has mention(s) in it.
Solution:
Created a new helper function to check whether a comment is empty or not by allowing only
imgandmention-component(custom mention component) tags.Media:
Screen.Recording.2024-08-30.at.17.34.50.mov
Screen.Recording.2024-08-30.at.17.33.26.mov
Plane issue: WEB-2348
Summary by CodeRabbit
New Features
isCommentEmpty, to streamline the process of checking if a comment is empty.isEmptyHtmlStringfunction to accept customizable allowed HTML tags for greater flexibility in sanitizing HTML content.Bug Fixes
Refactor
isEmptyHtmlStringwith the more semantically appropriateisCommentEmpty.