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

fix: Comments cannot be edited or deleted #2725

Merged
merged 6 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading