diff --git a/packages/grafana-ui/src/components/ElementSelectionContext/ElementSelectionContext.tsx b/packages/grafana-ui/src/components/ElementSelectionContext/ElementSelectionContext.tsx index 8ba48a7eeda..61627b0762c 100644 --- a/packages/grafana-ui/src/components/ElementSelectionContext/ElementSelectionContext.tsx +++ b/packages/grafana-ui/src/components/ElementSelectionContext/ElementSelectionContext.tsx @@ -45,6 +45,12 @@ export function useElementSelection(id: string | undefined): UseElementSelection // To prevent this click form clearing the selection evt.stopPropagation(); + // Prevent text selection caused by shift click + if (evt.shiftKey) { + evt.preventDefault(); + window.getSelection()?.empty(); + } + context.onSelect({ id }, evt.shiftKey); }, [context, id] diff --git a/packages/grafana-ui/src/components/Tabs/Tab.tsx b/packages/grafana-ui/src/components/Tabs/Tab.tsx index edbe71c965c..7b8cffdc428 100644 --- a/packages/grafana-ui/src/components/Tabs/Tab.tsx +++ b/packages/grafana-ui/src/components/Tabs/Tab.tsx @@ -24,10 +24,11 @@ export interface TabProps extends HTMLProps { counter?: number | null; /** Extra content, displayed after the tab label and counter */ suffix?: NavModelItem['tabSuffix']; + truncate?: boolean; } export const Tab = React.forwardRef( - ({ label, active, icon, onChangeTab, counter, suffix: Suffix, className, href, ...otherProps }, ref) => { + ({ label, active, icon, onChangeTab, counter, suffix: Suffix, className, href, truncate, ...otherProps }, ref) => { const tabsStyles = useStyles2(getStyles); const clearStyles = useStyles2(clearButtonStyles); @@ -40,7 +41,12 @@ export const Tab = React.forwardRef( ); - const linkClass = cx(clearStyles, tabsStyles.link, active ? tabsStyles.activeStyle : tabsStyles.notActive); + const linkClass = cx( + clearStyles, + tabsStyles.link, + active ? tabsStyles.activeStyle : tabsStyles.notActive, + truncate && tabsStyles.linkTruncate + ); const commonProps = { className: linkClass, @@ -53,7 +59,7 @@ export const Tab = React.forwardRef( if (href) { return ( -
+
( } return ( -
+