Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Popover targetElementTag prop #2276

Merged
merged 2 commits into from
Mar 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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