Skip to content

Commit

Permalink
fix: expanded comment input focus issue
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshmane7218 committed Dec 28, 2023
1 parent 44754e1 commit 466049f
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions packages/nc-gui/components/smartsheet/expanded-form/Comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,19 @@ const editLog = ref<AuditType>()
const isEditing = ref<boolean>(false)
const commentInputDomRef = ref<HTMLInputElement>()
const isCommentMode = ref(false)
const focusCommentInput: VNodeRef = (el) => {
if (!isExpandedFormLoading.value && (isCommentMode.value || isExpandedFormCommentMode.value) && !isEditing.value) {
if (isExpandedFormCommentMode.value) {
setTimeout(() => {
isExpandedFormCommentMode.value = false
}, 400)
}
return (el as HTMLInputElement)?.focus()
}
return el
}
const focusInput: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
function onKeyDown(event: KeyboardEvent) {
Expand All @@ -55,6 +66,9 @@ function onKeyEsc(event: KeyboardEvent) {
async function onEditComment() {
if (!isEditing.value || !editLog.value) return
isCommentMode.value = true
await updateComment(editLog.value.id!, {
description: editLog.value.description,
})
Expand Down Expand Up @@ -106,6 +120,7 @@ const isSaving = ref(false)
const saveComment = async () => {
if (isSaving.value) return
isCommentMode.value = true
isSaving.value = true
try {
Expand All @@ -117,10 +132,6 @@ const saveComment = async () => {
} finally {
isSaving.value = false
}
nextTick(() => {
commentInputDomRef.value?.focus()
})
}
watch(commentsWrapperEl, () => {
Expand All @@ -132,15 +143,6 @@ const onClickAudit = () => {
tab.value = 'audits'
}
watch(commentInputDomRef, () => {
if (commentInputDomRef.value && isExpandedFormCommentMode.value) {
setTimeout(() => {
commentInputDomRef.value?.focus()
isExpandedFormCommentMode.value = false
}, 400)
}
})
</script>

<template>
Expand Down Expand Up @@ -258,7 +260,7 @@ watch(commentInputDomRef, () => {
<div class="h-14 flex flex-row w-full bg-white py-2.75 px-1.5 items-center rounded-xl border-1 border-gray-200">
<GeneralUserIcon size="base" class="!w-10" :email="user?.email" :name="user?.display_name" />
<a-input
ref="commentInputDomRef"
:ref="focusCommentInput"
v-model:value="comment"
class="!rounded-lg border-1 bg-white !px-2.5 !py-2 !border-gray-200 nc-comment-box !outline-none"
placeholder="Start typing..."
Expand Down

1 comment on commit 466049f

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR changes have been deployed. Please run the following command to verify:

docker run -d -p 8888:8080 nocodb/nocodb-timely:0.203.0-pr-7298-20231228-1038

Please sign in to comment.