Browse Source

feat(gui): replace ClampText with css to improve performance of grid view

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5392/head
Pranav C 2 years ago
parent
commit
1f4465b1de
  1. 37
      packages/nc-gui/components/cell/ClampedText.vue

37
packages/nc-gui/components/cell/ClampedText.vue

@ -3,35 +3,18 @@ const props = defineProps<{
value?: string | number | null
lines?: number
}>()
const wrapper = ref()
const key = ref(0)
const debouncedRefresh = useDebounceFn(() => {
key.value++
}, 500)
onMounted(() => {
const observer = new ResizeObserver(() => {
debouncedRefresh()
})
observer.observe(wrapper.value)
})
</script>
<template>
<div ref="wrapper">
<!--
using '' for :text in text-clamp would keep the previous cell value after changing a filter
use ' ' instead of '' to trigger update
-->
<text-clamp
:key="`clamp-${key}-${props.value?.toString().length || 0}`"
class="w-full h-full break-word"
:text="`${props.value || ' '}`"
:max-lines="props.lines || 1"
/>
<div
:style="{
'display': '-webkit-box',
'max-width': '100%',
'-webkit-line-clamp': props.lines || 1,
'-webkit-box-orient': 'vertical',
'overflow': 'hidden',
}"
>
{{ props.value || '' }}
</div>
</template>

Loading…
Cancel
Save