Skip to content

Commit caafbb5

Browse files
authored
Fixes : tags, comments (#283)
#283 * Fix add tags menu * Don't save comment when it is empty * Add Changeset
1 parent 96a275d commit caafbb5

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

.changeset/two-steaks-unite.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'mexit-webapp': patch
3+
---
4+
5+
Fix tag menu, no empty comments

apps/webapp/src/Components/CommentsAndReactions/Comments.tsx

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import deleteBin6Line from '@iconify/icons-ri/delete-bin-6-line'
2-
import { Comment as CommentType, defaultContent, NodeEditorContent } from '@mexit/core'
2+
import { Comment as CommentType, defaultContent, mog, NodeEditorContent } from '@mexit/core'
33
import { RelativeTime } from '@mexit/shared'
44
import { PlateProvider } from '@udecode/plate'
55
import { IconButton } from '@workduck-io/mex-components'
66
import { tinykeys } from '@workduck-io/tinykeys'
77
import React, { useCallback, useEffect, useMemo } from 'react'
88
import { useMentions } from '../../Hooks/useMentions'
99
import { useAuthStore } from '../../Stores/useAuth'
10+
import { areEqual } from '../../Utils/hash'
1011
import { CommentEditor } from '../CommentEditor'
1112
import { CommentEditorWrapper } from '../CommentEditor/styled'
1213
import Plateless from '../Editor/Plateless'
1314
import { ProfileImage } from '../User/ProfileImage'
1415
import {
15-
CommentActions,
16-
CommentAuthor,
17-
CommentContentWrapper,
18-
CommentHeader,
19-
CommentsWrapper,
20-
CommentTime,
21-
CommentWrapper,
22-
NewCommentWrapper
16+
CommentActions,
17+
CommentAuthor,
18+
CommentContentWrapper,
19+
CommentHeader,
20+
CommentsWrapper,
21+
CommentTime,
22+
CommentWrapper,
23+
NewCommentWrapper
2324
} from './Comments.style'
2425

2526
type OnAddComment = (content: NodeEditorContent) => Promise<void>
@@ -90,6 +91,7 @@ export const NewComment = ({ onAddComment, byUser }: NewCommentProps) => {
9091
}
9192

9293
const onSubmit = useCallback(() => {
94+
if (areEqual(content, defaultContent.content)) return
9395
onAddComment(content)
9496
.then(() => {
9597
setContent(defaultContent.content)

libs/shared/src/Components/FloatingElements/Dropdown.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ export const MenuComponent = forwardRef<any, Props & React.HTMLProps<HTMLButtonE
279279
const newChildren = Children.map(children, (child) => {
280280
if (isValidElement(child) && filtered.includes(child.props.label)) {
281281
return child
282-
}
283-
})
282+
} else return null
283+
}).filter((child) => child !== null)
284284
setFilteredChildren(newChildren)
285285
}
286286
if (search === '') {
@@ -376,8 +376,8 @@ export const MenuComponent = forwardRef<any, Props & React.HTMLProps<HTMLButtonE
376376
ref(node: HTMLButtonElement) {
377377
listItemsRef.current[index] = node
378378
},
379-
onClick() {
380-
child.props.onClick?.()
379+
onClick(e) {
380+
child.props.onClick?.(e)
381381
tree?.events.emit('click')
382382
},
383383
// By default `focusItemOnHover` uses `mousemove` to sync focus,

0 commit comments

Comments
 (0)