Skip to content

Commit

Permalink
Introduce disable tooltip on hover property (opensearch-project#313) (o…
Browse files Browse the repository at this point in the history
…pensearch-project#314)

Added new property that allows users to disable tooltip
on hover. The default value is false to keep
backward compatability. We will revisit the ideal
default value based on user's feedback in later release.

Signed-off-by: Vijayan Balasubramanian <[email protected]>
(cherry picked from commit d0ef1fd)
  • Loading branch information
opensearch-trigger-bot[bot] authored and A9 Swift Project User committed Mar 13, 2023
1 parent 7cacad8 commit 0e29311
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions auto_sync_commit_metadata.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"last_github_commit": "33bf667169b930cedb195c69233b756ff3741bd0",
"last_gitfarm_commit": "827819d67122a9df9f9fe3a9cddfc8dfef929a3b"
"last_github_commit": "d0ef1fdabbfe5daa94d54e46dfca0c040c3c7b89",
"last_gitfarm_commit": "b3114197db3072912a213eacbf92c871ae4d5adc"
}
1 change: 1 addition & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const DOCUMENTS_MIN_MARKER_BORDER_THICKNESS = 0;
export const DOCUMENTS_MAX_MARKER_BORDER_THICKNESS = 100;
export const DOCUMENTS_DEFAULT_REQUEST_NUMBER = 1000;
export const DOCUMENTS_DEFAULT_SHOW_TOOLTIPS: boolean = false;
export const DOCUMENTS_DEFAULT_DISABLE_TOOLTIPS_ON_HOVER: boolean = false;
export const DOCUMENTS_DEFAULT_TOOLTIPS: string[] = [];
export const LAYER_PANEL_HIDE_LAYER_ICON = 'eyeClosed';
export const LAYER_PANEL_SHOW_LAYER_ICON = 'eye';
Expand Down
10 changes: 8 additions & 2 deletions public/components/map_container/map_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import {
Query,
} from '../../../../../src/plugins/data/public';
import { MapState } from '../../model/mapState';
import { createPopup, getPopupLocation, isTooltipEnabledLayer } from '../tooltip/create_tooltip';
import {
createPopup,
getPopupLocation,
isTooltipEnabledLayer,
isTooltipEnabledOnHover,
} from '../tooltip/create_tooltip';
import {
handleDataLayerRender,
handleReferenceLayerRender,
Expand Down Expand Up @@ -149,11 +154,12 @@ export const MapContainer = ({
// remove previous popup
hoverPopup?.remove();

const tooltipEnabledLayersOnHover = layers.filter(isTooltipEnabledOnHover);
const features = maplibreRef.current?.queryRenderedFeatures(e.point);
if (features && maplibreRef.current) {
hoverPopup = createPopup({
features,
layers: tooltipEnabledLayers,
layers: tooltipEnabledLayersOnHover,
// enable close button to avoid occasional dangling tooltip that is not cleared during mouse leave action
showCloseButton: true,
showPagination: false,
Expand Down
6 changes: 6 additions & 0 deletions public/components/tooltip/create_tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export function isTooltipEnabledLayer(
);
}

export function isTooltipEnabledOnHover(
layer: MapLayerSpecification
): layer is DocumentLayerSpecification {
return isTooltipEnabledLayer(layer) && !layer.source?.disableTooltipsOnHover;
}

export function groupFeaturesByLayers(
features: MapGeoJSONFeature[],
layers: DocumentLayerSpecification[]
Expand Down
1 change: 1 addition & 0 deletions public/model/mapLayerType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type DocumentLayerSpecification = {
geoFieldName: string;
documentRequestNumber: number;
showTooltips: boolean;
disableTooltipsOnHover?: boolean;
tooltipFields: string[];
useGeoBoundingBoxFilter: boolean;
filters: Filter[];
Expand Down
2 changes: 2 additions & 0 deletions public/utils/getIntialConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
MAP_REFERENCE_LAYER_DEFAULT_OPACITY,
OPENSEARCH_MAP_LAYER,
CUSTOM_MAP,
DOCUMENTS_DEFAULT_DISABLE_TOOLTIPS_ON_HOVER,
} from '../../common';
import { MapState } from '../model/mapState';
import { ConfigSchema } from '../../common/config';
Expand Down Expand Up @@ -53,6 +54,7 @@ export const getLayerConfigMap = (mapConfig: ConfigSchema) => ({
documentRequestNumber: DOCUMENTS_DEFAULT_REQUEST_NUMBER,
tooltipFields: DOCUMENTS_DEFAULT_TOOLTIPS,
showTooltips: DOCUMENTS_DEFAULT_SHOW_TOOLTIPS,
disableTooltipsOnHover: DOCUMENTS_DEFAULT_DISABLE_TOOLTIPS_ON_HOVER,
},
style: {
...getStyleColor(),
Expand Down

0 comments on commit 0e29311

Please sign in to comment.