Browse Source

fix : added showOnTruncateOnly prop in tooltip component

pull/7163/head
Mohammed Musharaf 1 year ago committed by musharaf-nocodb
parent
commit
38239a8dd3
  1. 1
      packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue
  2. 5
      packages/nc-gui/components/dashboard/TreeView/TableNode.vue
  3. 2
      packages/nc-gui/components/dashboard/TreeView/ViewsNode.vue
  4. 6
      packages/nc-gui/components/dashboard/settings/UIAcl.vue
  5. 11
      packages/nc-gui/components/nc/Tooltip.vue
  6. 2
      packages/nc-gui/components/project/View.vue
  7. 2
      packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue
  8. 2
      packages/nc-gui/components/smartsheet/details/Fields.vue
  9. 1
      packages/nc-gui/components/smartsheet/header/Cell.vue
  10. 2
      packages/nc-gui/components/smartsheet/header/VirtualCell.vue
  11. 6
      packages/nc-gui/components/smartsheet/toolbar/CreateSort.vue
  12. 5
      packages/nc-gui/components/smartsheet/toolbar/FieldListAutoCompleteDropdown.vue
  13. 8
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  14. 2
      packages/nc-gui/components/smartsheet/toolbar/OpenedViewAction.vue
  15. 4
      packages/nc-gui/components/smartsheet/toolbar/SearchData.vue
  16. 4
      tests/playwright/pages/Dashboard/Grid/index.ts

1
packages/nc-gui/components/dashboard/TreeView/ProjectNode.vue

@ -429,6 +429,7 @@ const projectDelete = () => {
class="nc-sidebar-node-title capitalize text-ellipsis overflow-hidden select-none" class="nc-sidebar-node-title capitalize text-ellipsis overflow-hidden select-none"
:style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }" :style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }"
:class="{ 'text-black font-semibold': activeProjectId === base.id && baseViewOpen }" :class="{ 'text-black font-semibold': activeProjectId === base.id && baseViewOpen }"
:showOnTruncateOnly="true"
> >
<template #title>{{ base.title }}</template> <template #title>{{ base.title }}</template>
<span @click="onProjectClick(base)"> <span @click="onProjectClick(base)">

5
packages/nc-gui/components/dashboard/TreeView/TableNode.vue

@ -231,7 +231,10 @@ const isTableOpened = computed(() => {
</div> </div>
</div> </div>
</div> </div>
<NcTooltip class="nc-tbl-title nc-sidebar-node-title text-ellipsis w-full overflow-hidden select-none"> <NcTooltip
class="nc-tbl-title nc-sidebar-node-title text-ellipsis w-full overflow-hidden select-none"
:showOnTruncateOnly="true"
>
<template #title>{{ table.title }}</template> <template #title>{{ table.title }}</template>
<span <span
:class="{ :class="{

2
packages/nc-gui/components/dashboard/TreeView/ViewsNode.vue

@ -232,7 +232,7 @@ watch(isDropdownOpen, async () => {
@blur="onRename" @blur="onRename"
@keydown.stop="onKeyDown($event)" @keydown.stop="onKeyDown($event)"
/> />
<NcTooltip v-else class="nc-sidebar-node-title text-ellipsis overflow-hidden select-none w-full"> <NcTooltip v-else class="nc-sidebar-node-title text-ellipsis overflow-hidden select-none w-full" :showOnTruncateOnly="true">
<template #title> {{ vModel.alias || vModel.title }}</template> <template #title> {{ vModel.alias || vModel.title }}</template>
<div <div
data-testid="sidebar-view-title" data-testid="sidebar-view-title"

6
packages/nc-gui/components/dashboard/settings/UIAcl.vue

@ -147,7 +147,7 @@ const toggleSelectAll = (role: Role) => {
<template> <template>
<div class="flex flex-row w-full items-center justify-center"> <div class="flex flex-row w-full items-center justify-center">
<div class="flex flex-col w-[900px]"> <div class="flex flex-col w-[900px]">
<NcTooltip class="mb-4 first-letter:capital font-bold max-w-100 truncate"> <NcTooltip class="mb-4 first-letter:capital font-bold max-w-100 truncate" :showOnTruncateOnly="true">
<template #title>{{ base.title }}</template> <template #title>{{ base.title }}</template>
<span> UI ACL : {{ base.title }} </span> <span> UI ACL : {{ base.title }} </span>
</NcTooltip> </NcTooltip>
@ -211,7 +211,7 @@ const toggleSelectAll = (role: Role) => {
<div class="min-w-5 flex items-center justify-center"> <div class="min-w-5 flex items-center justify-center">
<GeneralTableIcon :meta="{ meta: record.table_meta, type: record.ptype }" class="text-gray-500" /> <GeneralTableIcon :meta="{ meta: record.table_meta, type: record.ptype }" class="text-gray-500" />
</div> </div>
<NcTooltip class="overflow-ellipsis min-w-0 shrink-1 truncate"> <NcTooltip class="overflow-ellipsis min-w-0 shrink-1 truncate" :showOnTruncateOnly="true">
<template #title>{{ record._ptn }}</template> <template #title>{{ record._ptn }}</template>
<span>{{ record._ptn }}</span> <span>{{ record._ptn }}</span>
</NcTooltip> </NcTooltip>
@ -223,7 +223,7 @@ const toggleSelectAll = (role: Role) => {
<div class="min-w-5 flex items-center justify-center"> <div class="min-w-5 flex items-center justify-center">
<GeneralViewIcon :meta="record" class="text-gray-500"></GeneralViewIcon> <GeneralViewIcon :meta="record" class="text-gray-500"></GeneralViewIcon>
</div> </div>
<NcTooltip class="overflow-ellipsis min-w-0 shrink-1 truncate"> <NcTooltip class="overflow-ellipsis min-w-0 shrink-1 truncate" :showOnTruncateOnly="true">
<template #title>{{ record.title }}</template> <template #title>{{ record.title }}</template>
<span>{{ record.title }}</span> <span>{{ record.title }}</span>
</NcTooltip> </NcTooltip>

11
packages/nc-gui/components/nc/Tooltip.vue

@ -11,6 +11,7 @@ interface Props {
// force disable tooltip // force disable tooltip
disabled?: boolean disabled?: boolean
placement?: TooltipPlacement | undefined placement?: TooltipPlacement | undefined
showOnTruncateOnly?: boolean
hideOnClick?: boolean hideOnClick?: boolean
overlayClassName?: string overlayClassName?: string
} }
@ -20,6 +21,7 @@ const props = defineProps<Props>()
const modifierKey = computed(() => props.modifierKey) const modifierKey = computed(() => props.modifierKey)
const tooltipStyle = computed(() => props.tooltipStyle) const tooltipStyle = computed(() => props.tooltipStyle)
const disabled = computed(() => props.disabled) const disabled = computed(() => props.disabled)
const showOnTruncateOnly = computed(() => props?.showOnTruncateOnly)
const hideOnClick = computed(() => props.hideOnClick) const hideOnClick = computed(() => props.hideOnClick)
const placement = computed(() => props.placement ?? 'top') const placement = computed(() => props.placement ?? 'top')
@ -65,6 +67,15 @@ onKeyStroke(
) )
watch([isHovering, () => modifierKey.value, () => disabled.value], ([hovering, key, isDisabled]) => { watch([isHovering, () => modifierKey.value, () => disabled.value], ([hovering, key, isDisabled]) => {
if (showOnTruncateOnly?.value) {
const targetElement = el?.value
const isElementTruncated = targetElement?.scrollWidth > targetElement?.clientWidth
if (!isElementTruncated) {
showTooltip.value = false
return
}
}
if (!hovering || isDisabled) { if (!hovering || isDisabled) {
showTooltip.value = false showTooltip.value = false
return return

2
packages/nc-gui/components/project/View.vue

@ -75,7 +75,7 @@ watch(
<GeneralOpenLeftSidebarBtn /> <GeneralOpenLeftSidebarBtn />
<div class="flex flex-row items-center h-full gap-x-2.5"> <div class="flex flex-row items-center h-full gap-x-2.5">
<GeneralProjectIcon :type="openedProject?.type" /> <GeneralProjectIcon :type="openedProject?.type" />
<NcTooltip class="flex font-medium text-sm capitalize truncate max-w-150"> <NcTooltip class="flex font-medium text-sm capitalize truncate max-w-150" :showOnTruncateOnly="true">
<template #title> {{ openedProject?.title }}</template> <template #title> {{ openedProject?.title }}</template>
<span class="truncate"> <span class="truncate">
{{ openedProject?.title }} {{ openedProject?.title }}

2
packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue

@ -82,7 +82,7 @@ const isLinks = computed(() => vModel.value.uidt === UITypes.Links)
<div class="min-w-5 flex items-center justify-center"> <div class="min-w-5 flex items-center justify-center">
<GeneralTableIcon :meta="table" class="text-gray-500" /> <GeneralTableIcon :meta="table" class="text-gray-500" />
</div> </div>
<NcTooltip class="flex-1 truncate"> <NcTooltip class="flex-1 truncate" :showOnTruncateOnly="true">
<template #title>{{ table.title }}</template> <template #title>{{ table.title }}</template>
<span>{{ table.title }}</span> <span>{{ table.title }}</span>
</NcTooltip> </NcTooltip>

2
packages/nc-gui/components/smartsheet/details/Fields.vue

@ -819,6 +819,7 @@ const onFieldOptionUpdate = () => {
'text-brand-500': compareCols(field, activeField), 'text-brand-500': compareCols(field, activeField),
}" }"
class="truncate flex-1" class="truncate flex-1"
:showOnTruncateOnly="true"
> >
<template #title> {{ fieldState(field)?.title || field.title }} </template> <template #title> {{ fieldState(field)?.title || field.title }} </template>
<span> <span>
@ -978,6 +979,7 @@ const onFieldOptionUpdate = () => {
:class="{ :class="{
'text-brand-500': compareCols(displayColumn, activeField), 'text-brand-500': compareCols(displayColumn, activeField),
}" }"
:showOnTruncateOnly="true"
> >
<template #title> {{ fieldState(displayColumn)?.title || displayColumn.title }} </template> <template #title> {{ fieldState(displayColumn)?.title || displayColumn.title }} </template>
<span> <span>

1
packages/nc-gui/components/smartsheet/header/Cell.vue

@ -99,6 +99,7 @@ const onClick = (e: Event) => {
}" }"
class="name pl-1" class="name pl-1"
placement="bottom" placement="bottom"
:showOnTruncateOnly="true"
> >
<template #title> {{ column.title }} </template> <template #title> {{ column.title }} </template>

2
packages/nc-gui/components/smartsheet/header/VirtualCell.vue

@ -154,7 +154,7 @@ const openDropDown = (e: Event) => {
> >
<LazySmartsheetHeaderVirtualCellIcon v-if="column && !props.hideIcon" /> <LazySmartsheetHeaderVirtualCellIcon v-if="column && !props.hideIcon" />
<NcTooltip placement="bottom" class="truncate name pl-1"> <NcTooltip placement="bottom" class="truncate name pl-1" :showOnTruncateOnly="true">
<template #title> <template #title>
{{ tooltipMsg }} {{ tooltipMsg }}
</template> </template>

6
packages/nc-gui/components/smartsheet/toolbar/CreateSort.vue

@ -104,11 +104,11 @@ const onArrowUp = () => {
@click="onClick(option)" @click="onClick(option)"
> >
<SmartsheetHeaderIcon :column="option" /> <SmartsheetHeaderIcon :column="option" />
<NcTooltip class="truncate"> <NcTooltip class="truncate" :showOnTruncateOnly="true">
<template #title> {{ option.title }}</template> <template #title> {{ option.title }}</template>
<span> <template #default>
{{ option.title }} {{ option.title }}
</span> </template>
</NcTooltip> </NcTooltip>
</div> </div>
</div> </div>

5
packages/nc-gui/components/smartsheet/toolbar/FieldListAutoCompleteDropdown.vue

@ -85,11 +85,12 @@ if (!localValue.value && allowEmpty !== true) {
<NcTooltip <NcTooltip
:style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }" :style="{ wordBreak: 'keep-all', whiteSpace: 'nowrap', display: 'inline' }"
class="max-w-[15rem] truncate select-none" class="max-w-[15rem] truncate select-none"
:showOnTruncateOnly="true"
> >
<template #title> {{ option.label }}</template> <template #title> {{ option.label }}</template>
<span> <template #default>
{{ option.label }} {{ option.label }}
</span> </template>
</NcTooltip> </NcTooltip>
</div> </div>
</a-select-option> </a-select-option>

8
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -380,11 +380,11 @@ useMenuCloseOnEsc(open)
" "
> >
<component :is="getIcon(metaColumnById[field.fk_column_id])" /> <component :is="getIcon(metaColumnById[field.fk_column_id])" />
<NcTooltip :disabled="field.title.length < 30" class="flex-1 px-1 truncate"> <NcTooltip :showOnTruncateOnly="true" class="flex-1 px-1 truncate">
<template #title> <template #title>
{{ field.title }} {{ field.title }}
</template> </template>
<span>{{ field.title }}</span> <template #default>{{ field.title }}</template>
</NcTooltip> </NcTooltip>
<NcSwitch v-e="['a:fields:show-hide']" :checked="field.show" :disabled="field.isViewEssentialField" /> <NcSwitch v-e="['a:fields:show-hide']" :checked="field.show" :disabled="field.isViewEssentialField" />
@ -406,9 +406,9 @@ useMenuCloseOnEsc(open)
@click.stop @click.stop
> >
<component :is="getIcon(metaColumnById[filteredFieldList[0].fk_column_id as string])" /> <component :is="getIcon(metaColumnById[filteredFieldList[0].fk_column_id as string])" />
<NcTooltip :disabled="filteredFieldList?.[0]?.title?.length < 30" class="px-1 flex-1 truncate"> <NcTooltip :showOnTruncateOnly="true" class="px-1 flex-1 truncate">
<template #title>{{ filteredFieldList[0].title }}</template> <template #title>{{ filteredFieldList[0].title }}</template>
<span>{{ filteredFieldList[0].title }}</span> <template #default>{{ filteredFieldList[0].title }}</template>
</NcTooltip> </NcTooltip>
<NcSwitch v-e="['a:fields:show-hide']" :checked="true" :disabled="true" /> <NcSwitch v-e="['a:fields:show-hide']" :checked="true" :disabled="true" />

2
packages/nc-gui/components/smartsheet/toolbar/OpenedViewAction.vue

@ -182,7 +182,7 @@ function openDeleteDialog() {
'text-gray-800 font-medium': !activeView?.is_default, 'text-gray-800 font-medium': !activeView?.is_default,
}" }"
> >
<NcTooltip class="truncate xs:pl-1.25 flex-1 text-inherit"> <NcTooltip class="truncate xs:pl-1.25 flex-1 text-inherit" :showOnTruncateOnly="true">
<template #title>{{ activeView?.is_default ? $t('title.defaultView') : activeView?.title }} </template> <template #title>{{ activeView?.is_default ? $t('title.defaultView') : activeView?.title }} </template>
<span <span
:class="{ :class="{

4
packages/nc-gui/components/smartsheet/toolbar/SearchData.vue

@ -114,9 +114,9 @@ watch(columns, () => {
<a-select-option v-for="op of columns" :key="op.value" v-e="['c:search:field:select']" :value="op.value"> <a-select-option v-for="op of columns" :key="op.value" v-e="['c:search:field:select']" :value="op.value">
<div class="text-[0.75rem] flex items-center -ml-1 gap-2"> <div class="text-[0.75rem] flex items-center -ml-1 gap-2">
<SmartsheetHeaderIcon class="text-sm" :column="op.column" /> <SmartsheetHeaderIcon class="text-sm" :column="op.column" />
<NcTooltip class="truncate" placement="top"> <NcTooltip class="truncate" placement="top" :showOnTruncateOnly="true">
<template #title>{{ op.label }}</template> <template #title>{{ op.label }}</template>
<span>{{ op.label }}</span> <template #default>{{ op.label }}</template>
</NcTooltip> </NcTooltip>
</div> </div>
</a-select-option> </a-select-option>

4
tests/playwright/pages/Dashboard/Grid/index.ts

@ -129,7 +129,7 @@ export class GridPage extends BasePage {
await this._fillRow({ index, columnHeader, value: rowValue }); await this._fillRow({ index, columnHeader, value: rowValue });
const clickOnColumnHeaderToSave = () => const clickOnColumnHeaderToSave = () =>
this.get().locator(`[data-title="${columnHeader}"]`).locator(`div[data-test-id="${columnHeader}"]`).click(); this.get().locator(`[data-title="${columnHeader}"]`).locator(`span[data-test-id="${columnHeader}"]`).click();
if (networkValidation) { if (networkValidation) {
await this.waitForResponse({ await this.waitForResponse({
@ -164,7 +164,7 @@ export class GridPage extends BasePage {
await this._fillRow({ index, columnHeader, value }); await this._fillRow({ index, columnHeader, value });
const clickOnColumnHeaderToSave = () => const clickOnColumnHeaderToSave = () =>
this.get().locator(`[data-title="${columnHeader}"]`).locator(`div[data-test-id="${columnHeader}"]`).click(); this.get().locator(`[data-title="${columnHeader}"]`).locator(`span[data-test-id="${columnHeader}"]`).click();
if (networkValidation) { if (networkValidation) {
await this.waitForResponse({ await this.waitForResponse({

Loading…
Cancel
Save