Skip to content

Commit 5343bc9

Browse files
committed
fix(knowledge): prevent navigation on context menu actions and widen tags modal
1 parent d5bea5f commit 5343bc9

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/[documentId]/components/document-tags-modal/document-tags-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export function DocumentTagsModal({
383383

384384
return (
385385
<Modal open={open} onOpenChange={handleClose}>
386-
<ModalContent size='sm'>
386+
<ModalContent size='md'>
387387
<ModalHeader>
388388
<div className='flex items-center justify-between'>
389389
<span>Document Tags</span>

apps/sim/app/workspace/[workspaceId]/knowledge/[id]/components/base-tags-modal/base-tags-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export function BaseTagsModal({ open, onOpenChange, knowledgeBaseId }: BaseTagsM
261261
return (
262262
<>
263263
<Modal open={open} onOpenChange={handleClose}>
264-
<ModalContent size='sm'>
264+
<ModalContent size='md'>
265265
<ModalHeader>
266266
<div className='flex items-center justify-between'>
267267
<span>Tags</span>

apps/sim/app/workspace/[workspaceId]/knowledge/components/base-card/base-card.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
22

3-
import { useCallback, useState } from 'react'
3+
import { useCallback, useRef, useState } from 'react'
44
import { useParams, useRouter } from 'next/navigation'
55
import { Badge, DocumentAttachment, Tooltip } from '@/components/emcn'
66
import { formatAbsoluteDate, formatRelativeTime } from '@/lib/core/utils/formatting'
@@ -100,6 +100,7 @@ export function BaseCard({
100100
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false)
101101
const [isTagsModalOpen, setIsTagsModalOpen] = useState(false)
102102
const [isDeleting, setIsDeleting] = useState(false)
103+
const actionTakenRef = useRef(false)
103104

104105
const searchParams = new URLSearchParams({
105106
kbName: title,
@@ -110,7 +111,7 @@ export function BaseCard({
110111

111112
const handleClick = useCallback(
112113
(e: React.MouseEvent) => {
113-
if (isContextMenuOpen) {
114+
if (isContextMenuOpen || actionTakenRef.current) {
114115
e.preventDefault()
115116
return
116117
}
@@ -130,19 +131,35 @@ export function BaseCard({
130131
)
131132

132133
const handleOpenInNewTab = useCallback(() => {
134+
actionTakenRef.current = true
133135
window.open(href, '_blank')
136+
requestAnimationFrame(() => {
137+
actionTakenRef.current = false
138+
})
134139
}, [href])
135140

136141
const handleViewTags = useCallback(() => {
142+
actionTakenRef.current = true
137143
setIsTagsModalOpen(true)
144+
requestAnimationFrame(() => {
145+
actionTakenRef.current = false
146+
})
138147
}, [])
139148

140149
const handleEdit = useCallback(() => {
150+
actionTakenRef.current = true
141151
setIsEditModalOpen(true)
152+
requestAnimationFrame(() => {
153+
actionTakenRef.current = false
154+
})
142155
}, [])
143156

144157
const handleDelete = useCallback(() => {
158+
actionTakenRef.current = true
145159
setIsDeleteModalOpen(true)
160+
requestAnimationFrame(() => {
161+
actionTakenRef.current = false
162+
})
146163
}, [])
147164

148165
const handleConfirmDelete = useCallback(async () => {

0 commit comments

Comments
 (0)