Skip to content

Commit

Permalink
Merge pull request #2725 from EandrewJones/fix/#2563
Browse files Browse the repository at this point in the history
fix: Comments cannot be edited or deleted
  • Loading branch information
12joan authored Nov 5, 2023
2 parents 9d2931b + f2b2d7f commit dcc3ec5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-poems-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-comments': major
---

Remove `useCommentValue`, which was redundant with the hooks applied automatically in `CommentEditTextarea.tsx`.
12 changes: 4 additions & 8 deletions apps/www/src/registry/default/plate-ui/comment-more-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {

export function CommentMoreDropdown() {
const editButtonState = useCommentEditButtonState();
const editProps = useCommentEditButton(editButtonState);
const { props: editProps } = useCommentEditButton(editButtonState);
const deleteButtonState = useCommentDeleteButtonState();
const deleteProps = useCommentDeleteButton(deleteButtonState);
const { props: deleteProps } = useCommentDeleteButton(deleteButtonState);

return (
<DropdownMenu modal={false}>
Expand All @@ -32,12 +32,8 @@ export function CommentMoreDropdown() {
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem {...(editProps as any)}>
Edit comment
</DropdownMenuItem>
<DropdownMenuItem {...(deleteProps as any)}>
Delete comment
</DropdownMenuItem>
<DropdownMenuItem {...editProps}>Edit comment</DropdownMenuItem>
<DropdownMenuItem {...deleteProps}>Delete comment</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
Expand Down
8 changes: 1 addition & 7 deletions apps/www/src/registry/default/plate-ui/comment-value.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ import React from 'react';
import {
CommentEditActions,
CommentEditTextarea,
useCommentValue,
} from '@udecode/plate-comments';

import { cn } from '@/lib/utils';
import { buttonVariants } from '@/registry/default/plate-ui/button';
import { inputVariants } from '@/registry/default/plate-ui/input';

export function CommentValue() {
const { textareaRef } = useCommentValue();

return (
<div className="my-2 flex flex-col items-end gap-2">
<CommentEditTextarea
ref={textareaRef}
className={cn(inputVariants(), 'min-h-[60px]')}
/>
<CommentEditTextarea className={cn(inputVariants(), 'min-h-[60px]')} />

<div className="flex space-x-2">
<CommentEditActions.CancelButton
Expand Down
1 change: 0 additions & 1 deletion packages/comments/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export * from './CommentsPositioner';
export * from './useCommentAddButton';
export * from './useCommentItemContent';
export * from './useCommentLeaf';
export * from './useCommentValue';
export * from './useCommentsShowResolvedButton';
export * from './useFloatingCommentsContentState';
export * from './useFloatingCommentsState';
17 changes: 0 additions & 17 deletions packages/comments/src/components/useCommentValue.ts

This file was deleted.

0 comments on commit dcc3ec5

Please sign in to comment.