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 active state to Popover2 when popover is open and target is a button #1872

Merged
merged 9 commits into from Dec 9, 2017
8 changes: 6 additions & 2 deletions packages/labs/src/components/popover/popover2.tsx
Expand Up @@ -264,9 +264,10 @@ export class Popover2 extends AbstractComponent<IPopover2Props, IPopover2State>
public render() {
const { className } = this.props;
const { isOpen, disabled, hasBackdrop } = this.state;
const isHoverInteractionKind = this.isHoverInteractionKind();

let targetProps: React.HTMLAttributes<HTMLElement>;
if (this.isHoverInteractionKind()) {
if (isHoverInteractionKind) {
targetProps = {
onBlur: this.handleTargetBlur,
onFocus: this.handleTargetFocus,
Expand All @@ -288,8 +289,11 @@ export class Popover2 extends AbstractComponent<IPopover2Props, IPopover2State>
);

const children = this.understandChildren();
const targetTabIndex = this.props.openOnTargetFocus && this.isHoverInteractionKind() ? 0 : undefined;
const targetTabIndex = this.props.openOnTargetFocus && isHoverInteractionKind ? 0 : undefined;
const target: JSX.Element = React.cloneElement(children.target, {
className: classNames(children.target.props.className, {
[Classes.ACTIVE]: isOpen && !isHoverInteractionKind,
}),
// force disable single Tooltip child when popover is open (BLUEPRINT-552)
disabled: isOpen && children.target.type === Tooltip2 ? true : children.target.props.disabled,
tabIndex: targetTabIndex,
Expand Down