Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/client/src/widgets/TableWidgetV2/component/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ export interface InlineEditingCellProperties {
export interface CellWrappingProperties {
allowCellWrapping: boolean;
}
export interface DisableTooltipProperties {
disableTooltip: boolean;
}

export interface ButtonCellProperties {
buttonVariant: ButtonVariant;
Expand Down Expand Up @@ -222,6 +225,7 @@ export interface CellLayoutProperties
extends EditActionCellProperties,
InlineEditingCellProperties,
CellWrappingProperties,
DisableTooltipProperties,
ButtonCellProperties,
URLCellProperties,
MenuButtonCellProperties,
Expand Down Expand Up @@ -285,6 +289,7 @@ export interface ColumnBaseProperties {
isAscOrder?: boolean;
alias: string;
allowCellWrapping: boolean;
disableTooltip: boolean;
}

export interface ColumnStyleProperties {
Expand Down Expand Up @@ -497,6 +502,7 @@ export interface BaseCellComponentProps {
compactMode: string;
isHidden: boolean;
allowCellWrapping?: boolean;
disableTooltip?: boolean;
horizontalAlignment?: CellAlignment;
verticalAlignment?: VerticalAlignment;
cellBackground?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { createRef, useEffect, useState } from "react";
import { Tooltip } from "@blueprintjs/core";
import { CellWrapper, TooltipContentWrapper } from "../TableStyledWrappers";
import type { CellAlignment, VerticalAlignment } from "../Constants";
import { importSvg } from "design-system-old";
import React, { createRef, useEffect, useState } from "react";
import styled from "styled-components";
import { ColumnTypes } from "widgets/TableWidgetV2/constants";
import { importSvg } from "design-system-old";
import type { CellAlignment, VerticalAlignment } from "../Constants";
import { CellWrapper, TooltipContentWrapper } from "../TableStyledWrappers";

const OpenNewTabIcon = importSvg(
async () => import("assets/icons/control/open-new-tab.svg"),
Expand Down Expand Up @@ -37,8 +37,8 @@ const TOOLTIP_OPEN_DELAY = 500;

function useToolTip(
children: React.ReactNode,
tableWidth?: number,
title?: string,
disableTooltip?: boolean,
) {
const ref = createRef<HTMLDivElement>();
const [requiresTooltip, setRequiresTooltip] = useState(false);
Expand All @@ -54,7 +54,11 @@ function useToolTip(
* during initial render
*/
timeout = setTimeout(() => {
if (element && element.offsetWidth < element.scrollWidth) {
const requiresTooltip =
!disableTooltip &&
element &&
element.offsetWidth < element.scrollWidth;
if (requiresTooltip) {
setRequiresTooltip(true);
} else {
setRequiresTooltip(false);
Expand Down Expand Up @@ -82,13 +86,11 @@ function useToolTip(
return requiresTooltip && children ? (
<Tooltip
autoFocus={false}
boundary="viewport"
content={
<TooltipContentWrapper width={MAX_WIDTH - WIDTH_OFFSET}>
{title}
</TooltipContentWrapper>
}
defaultIsOpen
hoverOpenDelay={TOOLTIP_OPEN_DELAY}
position="bottom"
usePortal
Expand Down Expand Up @@ -116,6 +118,7 @@ interface Props {
className?: string;
compactMode?: string;
allowCellWrapping?: boolean;
disableTooltip?: boolean;
horizontalAlignment?: CellAlignment;
verticalAlignment?: VerticalAlignment;
textColor?: string;
Expand All @@ -128,7 +131,7 @@ interface Props {
}

function LinkWrapper(props: Props) {
const content = useToolTip(props.children, props.tableWidth, props.title);
const content = useToolTip(props.children, props.title, props.disableTooltip);

return (
<CellWrapper
Expand Down Expand Up @@ -160,7 +163,7 @@ function LinkWrapper(props: Props) {
}

function AutoToolTipComponent(props: Props) {
const content = useToolTip(props.children, props.tableWidth, props.title);
const content = useToolTip(props.children, props.title, props.disableTooltip);

if (props.columnType === ColumnTypes.URL && props.title) {
return <LinkWrapper {...props} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const BasicCell = React.forwardRef(
compactMode,
disabledEditIcon,
disabledEditIconMessage,
disableTooltip,
fontStyle,
hasUnsavedChanges,
horizontalAlignment,
Expand Down Expand Up @@ -143,6 +144,7 @@ export const BasicCell = React.forwardRef(
className={isCellEditable ? "editable-cell" : ""}
columnType={columnType}
compactMode={compactMode}
disableTooltip={disableTooltip}
fontStyle={fontStyle}
horizontalAlignment={horizontalAlignment}
isCellDisabled={isCellDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function PlainTextCell(
decimals,
disabledEditIcon,
disabledEditIconMessage,
disableTooltip,
displayText,
fontStyle,
hasUnsavedChanges,
Expand Down Expand Up @@ -299,6 +300,7 @@ function PlainTextCell(
cellBackground={cellBackground}
columnType={columnType}
compactMode={compactMode}
disableTooltip={disableTooltip}
disabledEditIcon={disabledEditIcon}
disabledEditIconMessage={disabledEditIconMessage}
fontStyle={fontStyle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe("TransformTableDataIntoArrayOfArray", () => {
isCellEditable: false,
isEditable: false,
allowCellWrapping: false,
disableTooltip: false,
},
},
];
Expand Down
1 change: 1 addition & 0 deletions app/client/src/widgets/TableWidgetV2/widget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,7 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
compactMode={compactMode}
currencyCode={cellProperties.currencyCode}
decimals={cellProperties.decimals}
disableTooltip={cellProperties.disableTooltip}
disabledEditIcon={
shouldDisableEdit || this.props.isAddRowInProgress
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ export default {
]);
},
},
{
propertyName: "disableTooltip",
dependencies: ["primaryColumns", "columnType"],
label: "Disable tooltip",
helpText: "Hides tooltip on cell hover",
defaultValue: false,
controlType: "SWITCH",
customJSControl: "TABLE_COMPUTE_VALUE",
isJSConvertible: true,
isBindProperty: true,
isTriggerProperty: false,
validation: {
type: ValidationTypes.ARRAY_OF_TYPE_OR_TYPE,
params: {
type: ValidationTypes.BOOLEAN,
},
},
hidden: (props: TableWidgetProps, propertyPath: string) => {
return hideByColumnType(props, propertyPath, [ColumnTypes.TEXT]);
},
},
{
propertyName: "isCellEditable",
dependencies: [
Expand Down
5 changes: 5 additions & 0 deletions app/client/src/widgets/TableWidgetV2/widget/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export function getDefaultColumnProperties(
decimals: 0,
thousandSeparator: true,
notation: "standard" as Intl.NumberFormatOptions["notation"],
disableTooltip: false,
};

return columnProps;
Expand Down Expand Up @@ -523,6 +524,10 @@ export const getCellProperties = (
rowIndex,
),
notation: getPropertyValue(columnProperties.notation, rowIndex, true),
disableTooltip: getBooleanPropertyValue(
columnProperties.disableTooltip,
rowIndex,
),
} as CellLayoutProperties;
}
return {} as CellLayoutProperties;
Expand Down