From fb35d52ac98ee880a41e79f6e5c929ff5c898a49 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 10 Jul 2023 11:23:29 +0100 Subject: [PATCH] Add temporary tooltip to help creating the first row in grids --- packages/bbui/src/Tooltip/AbsTooltip.svelte | 8 +++-- .../src/components/grid/layout/NewRow.svelte | 31 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/packages/bbui/src/Tooltip/AbsTooltip.svelte b/packages/bbui/src/Tooltip/AbsTooltip.svelte index 3a2c035615..9be7251445 100644 --- a/packages/bbui/src/Tooltip/AbsTooltip.svelte +++ b/packages/bbui/src/Tooltip/AbsTooltip.svelte @@ -27,8 +27,8 @@ let wrapper let hovered = false - let left = 0 - let top = 0 + let left + let top let visible = false let timeout let interval @@ -48,6 +48,8 @@ const updateTooltipPosition = () => { const node = wrapper?.children?.[0] if (!node) { + left = null + top = null return } const bounds = node.getBoundingClientRect() @@ -98,7 +100,7 @@ -{#if visible && text} +{#if visible && text && left != null && top != null} import { getContext, onDestroy, onMount, tick } from "svelte" - import { Icon, Button } from "@budibase/bbui" + import { Icon, Button, TempTooltip, TooltipType } from "@budibase/bbui" import GridScrollWrapper from "./GridScrollWrapper.svelte" import DataCell from "../cells/DataCell.svelte" import { fade } from "svelte/transition" @@ -27,6 +27,8 @@ rowVerticalInversionIndex, columnHorizontalInversionIndex, selectedRows, + config, + canAddRows, } = getContext("grid") let visible = false @@ -39,6 +41,7 @@ $: $tableId, (visible = false) $: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows) $: selectedRowCount = Object.values($selectedRows).length + $: hasNoRows = !$rows.length const shouldInvertY = (offset, inversionIndex, rows) => { if (offset === 0) { @@ -146,16 +149,22 @@ -{#if !visible && !selectedRowCount} -
dispatch("add-row-inline")} - transition:fade|local={{ duration: 130 }} - class:offset={!$stickyColumn} - > - -
-{/if} + + {#if !visible && !selectedRowCount && $canAddRows} +
dispatch("add-row-inline")} + transition:fade|local={{ duration: 130 }} + class:offset={!$stickyColumn} + > + +
+ {/if} +
{#if visible}