Skip to content

Commit

Permalink
[Lens] Hide tooltips while dragging dimensions (#122198)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdaemon authored Jan 4, 2022
1 parent 4dcf22b commit c2f57dc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export function DraggableDimensionButton({
group,
groups,
onDrop,
onDragStart,
onDragEnd,
children,
layerDatasourceDropProps,
layerDatasource,
Expand All @@ -43,6 +45,8 @@ export function DraggableDimensionButton({
dropTarget: DragDropIdentifier,
dropType?: DropType
) => void;
onDragStart: () => void;
onDragEnd: () => void;
group: VisualizationDimensionGroupConfig;
groups: VisualizationDimensionGroupConfig[];
label: string;
Expand Down Expand Up @@ -143,6 +147,8 @@ export function DraggableDimensionButton({
reorderableGroup={reorderableGroup.length > 1 ? reorderableGroup : undefined}
value={value}
onDrop={handleOnDrop}
onDragStart={() => onDragStart()}
onDragEnd={() => onDragEnd()}
>
{children}
</DragDrop>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function LayerPanel(
const [activeDimension, setActiveDimension] = useState<ActiveDimensionState>(
initialActiveDimensionState
);
const [hideTooltip, setHideTooltip] = useState<boolean>(false);

const {
framePublicAPI,
Expand Down Expand Up @@ -459,6 +460,8 @@ export function LayerPanel(
layerDatasource={layerDatasource}
layerIndex={layerIndex}
layerId={layerId}
onDragStart={() => setHideTooltip(true)}
onDragEnd={() => setHideTooltip(false)}
onDrop={onDrop}
>
<div className="lnsLayerPanel__dimension">
Expand Down Expand Up @@ -506,6 +509,7 @@ export function LayerPanel(
columnId: accessorConfig.columnId,
groupId: group.groupId,
filterOperations: group.filterOperations,
hideTooltip,
invalid: group.invalid,
invalidMessage: group.invalidMessage,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const IndexPatternDimensionTriggerComponent = function IndexPatternDimens
const layerId = props.layerId;
const layer = props.state.layers[layerId];
const currentIndexPattern = props.state.indexPatterns[layer.indexPatternId];
const { columnId, uniqueLabel, invalid, invalidMessage } = props;
const { columnId, uniqueLabel, invalid, invalidMessage, hideTooltip } = props;

const currentColumnHasErrors = useMemo(
() => invalid || isColumnInvalid(layer, columnId, currentIndexPattern),
Expand All @@ -64,23 +64,23 @@ export const IndexPatternDimensionTriggerComponent = function IndexPatternDimens
const formattedLabel = wrapOnDot(uniqueLabel);

if (currentColumnHasErrors) {
let tooltipContent;
if (!hideTooltip) {
tooltipContent = invalidMessage ?? (
<p>
{i18n.translate('xpack.lens.configure.invalidConfigTooltip', {
defaultMessage: 'Invalid configuration.',
})}
<br />
{i18n.translate('xpack.lens.configure.invalidConfigTooltipClick', {
defaultMessage: 'Click for more details.',
})}
</p>
);
}

return (
<EuiToolTip
content={
invalidMessage ?? (
<p>
{i18n.translate('xpack.lens.configure.invalidConfigTooltip', {
defaultMessage: 'Invalid configuration.',
})}
<br />
{i18n.translate('xpack.lens.configure.invalidConfigTooltipClick', {
defaultMessage: 'Click for more details.',
})}
</p>
)
}
anchorClassName="eui-displayBlock"
>
<EuiToolTip content={tooltipContent} anchorClassName="eui-displayBlock">
<EuiText
size="s"
color="danger"
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export type DatasourceDimensionProps<T> = SharedDimensionProps & {
onRemove?: (accessor: string) => void;
state: T;
activeData?: Record<string, Datatable>;
hideTooltip?: boolean;
invalid?: boolean;
invalidMessage?: string;
};
Expand Down

0 comments on commit c2f57dc

Please sign in to comment.