From 3a644ae69e0d4a097bc5387824e8e3f11b35dd11 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:08:44 +0530 Subject: [PATCH] Nc fix/UI bug fixes (#8858) * fix(nc-gui): add hover effect if user came from comment url * fix(nc-gui): show rounded precision decimal value --- packages/nc-gui/components/cell/Decimal.vue | 11 ++++-- .../smartsheet/expanded-form/Comments.vue | 36 ++++++++++++++++--- .../smartsheet/expanded-form/RichComment.vue | 2 +- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/components/cell/Decimal.vue b/packages/nc-gui/components/cell/Decimal.vue index 92930c82fb..0263273dbd 100644 --- a/packages/nc-gui/components/cell/Decimal.vue +++ b/packages/nc-gui/components/cell/Decimal.vue @@ -35,14 +35,21 @@ const meta = computed(() => { const _vModel = useVModel(props, 'modelValue', emits) +function roundUpToPrecision(value: number, precision = 1) { + const factor = Math.pow(10, precision) + const roundedValue = Math.round(value * factor) / factor + + return roundedValue.toFixed(precision) +} + const displayValue = computed(() => { if (_vModel.value === null) return null if (isNaN(Number(_vModel.value))) return null - if (meta.value.isLocaleString) return (+Number(_vModel.value).toFixed(meta.value.precision ?? 1)).toLocaleString() + if (meta.value.isLocaleString) return roundUpToPrecision(Number(_vModel.value), meta.value.precision ?? 1).toLocaleString() - return Number(_vModel.value).toFixed(meta.value.precision ?? 1) + return roundUpToPrecision(Number(_vModel.value), meta.value.precision ?? 1) }) const vModel = computed({ diff --git a/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue b/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue index aca4c7b6f2..9a8570e40d 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/Comments.vue @@ -57,6 +57,8 @@ const isEditing = ref(false) const isCommentMode = ref(false) +const hoveredCommentId = ref(null) + async function onEditComment() { if (!isEditing.value || !editCommentValue.value?.comment) return @@ -196,6 +198,10 @@ watch(commentsWrapperEl, () => { }, }) scrollToComment(commentId as string) + + hoveredCommentId.value = commentId as string + + onClickOutside(document.querySelector(`.${hoveredCommentId.value}`)! as HTMLDivElement, handleResetHoverEffect) } else { scrollComments() } @@ -233,6 +239,12 @@ const editedAt = (comment: CommentType) => { } return '' } + +function handleResetHoverEffect() { + if (!hoveredCommentId.value) return + + hoveredCommentId.value = null +}