Skip to content

Commit

Permalink
Add Popover targetElementTag prop (#2276)
Browse files Browse the repository at this point in the history
* Adds ability to change target element for tooltips

* update prop name and doc string
  • Loading branch information
tgreen7 authored and giladgray committed Mar 19, 2018
1 parent bd79f40 commit afd0939
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/core/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ export interface IPopoverProps extends IOverlayableProps, IProps {
*/
targetClassName?: string;

/**
* The name of the HTML tag to use when rendering the popover target element.
* @default "div"
*/
targetElementTag?: string;

/**
* Whether the popover should be rendered inside a `Portal` attached to `document.body`.
* Rendering content inside a `Portal` allows the popover content to escape the physical bounds of its
Expand Down Expand Up @@ -221,6 +227,7 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState>
openOnTargetFocus: true,
position: "auto",
rootElementTag: "span",
targetElementTag: "div",
transitionDuration: 300,
usePortal: true,
};
Expand Down Expand Up @@ -259,7 +266,7 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState>
}

public render() {
const { className, disabled, hasBackdrop, targetClassName } = this.props;
const { className, disabled, hasBackdrop, targetClassName, targetElementTag } = this.props;
const { isOpen } = this.state;
const isHoverInteractionKind = this.isHoverInteractionKind();

Expand Down Expand Up @@ -305,7 +312,7 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState>

return (
<Manager tag={this.props.rootElementTag} className={classNames(Classes.POPOVER_WRAPPER, className)}>
<Target {...targetProps} innerRef={this.refHandlers.target}>
<Target {...targetProps} component={targetElementTag} innerRef={this.refHandlers.target}>
{target}
</Target>
<Overlay
Expand Down
6 changes: 6 additions & 0 deletions packages/core/src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export interface ITooltipProps extends IProps, IIntentProps {
*/
rootElementTag?: string;

/**
* The name of the HTML tag to use when rendering the popover target element.
* @default "div"
*/
targetElementTag?: string;

/**
* A space-delimited string of class names that are applied to the tooltip.
*/
Expand Down

1 comment on commit afd0939

@blueprint-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Popover targetElementTag prop (#2276)

Preview: documentation | landing | table

Please sign in to comment.