diff --git a/common/changes/feature-overflowTooltip2_2017-04-11-19-55.json b/common/changes/feature-overflowTooltip2_2017-04-11-19-55.json new file mode 100644 index 0000000000000..617321b847150 --- /dev/null +++ b/common/changes/feature-overflowTooltip2_2017-04-11-19-55.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "TooltipHost: Allow showing tooltip only if there's overflow", + "type": "minor" + } + ], + "email": "cschleid@microsoft.com" +} \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss index 8f7f07f20f5d7..d9cfceef9a672 100644 --- a/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss +++ b/packages/office-ui-fabric-react/src/components/Tooltip/Tooltip.scss @@ -1,4 +1,5 @@ @import '../../common/common'; + // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See LICENSE in the project root for license information. // // Office UI Fabric @@ -21,9 +22,4 @@ font-size: $ms-font-size-s; color: $ms-color-neutralPrimary; word-break: break-all; -} - -.host { - display: inline; -} - +} \ No newline at end of file diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts b/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts index 5b169c31b4f93..bbe34dc367139 100644 --- a/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts +++ b/packages/office-ui-fabric-react/src/components/Tooltip/TooltipHost.Props.ts @@ -8,6 +8,14 @@ export interface ITooltipHost { } +export enum TooltipOverflowMode { + /** Only show tooltip if parent DOM element is overflowing */ + Parent, + + /** Only show tooltip if tooltip host's content is overflowing */ + Self +} + /** * Tooltip component props. */ @@ -39,4 +47,10 @@ export interface ITooltipHostProps extends React.HTMLProps { - public static defaultProps = { delay: TooltipDelay.medium }; @@ -33,14 +34,15 @@ export class TooltipHost extends BaseComponent { public render() { @@ -29,6 +31,10 @@ export class TooltipPage extends React.Component { + + + + } propertiesTables={ diff --git a/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Overflow.Example.tsx b/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Overflow.Example.tsx new file mode 100644 index 0000000000000..938e809175fdf --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/Tooltip/examples/Tooltip.Overflow.Example.tsx @@ -0,0 +1,43 @@ +/* tslint:disable:no-unused-variable */ +import * as React from 'react'; +/* tslint:enable:no-unused-variable */ +import { BaseComponent, css } from 'office-ui-fabric-react/lib/Utilities'; +import { Button } from 'office-ui-fabric-react/lib/Button'; +import { + TooltipHost, + TooltipOverflowMode +} from 'office-ui-fabric-react/lib/Tooltip'; + +export class TooltipOverflowExample extends BaseComponent { + constructor(props: any) { + super(props); + + this.state = { + overflow: false + }; + } + + public render() { + return ( +
+ + +
+
+ + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec volutpat lectus ut magna sodales, sit amet accumsan arcu accumsan. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + +
+
+
+ ); + } +} \ No newline at end of file