diff --git a/packages/core/src/common/_mixins.scss b/packages/core/src/common/_mixins.scss index 3460509a3f9..3af661f3bf4 100644 --- a/packages/core/src/common/_mixins.scss +++ b/packages/core/src/common/_mixins.scss @@ -80,9 +80,9 @@ $pt-dark-intent-text-colors: ( word-wrap: normal; } -@mixin focus-outline() { +@mixin focus-outline($offset: 2px) { outline: rgba($blue3, 0.5) auto 2px; - outline-offset: 2px; + outline-offset: $offset; -moz-outline-radius: 6px; } diff --git a/packages/core/src/common/keys.ts b/packages/core/src/common/keys.ts index 625cc88527b..71ce5f11e66 100644 --- a/packages/core/src/common/keys.ts +++ b/packages/core/src/common/keys.ts @@ -5,6 +5,7 @@ * and https://github.com/palantir/blueprint/blob/master/PATENTS */ +export const BACKSPACE = 8; export const TAB = 9; export const ENTER = 13; export const SHIFT = 16; diff --git a/packages/core/src/components/button/abstractButton.tsx b/packages/core/src/components/button/abstractButton.tsx index 8c2d9e85671..2dc67b09187 100644 --- a/packages/core/src/components/button/abstractButton.tsx +++ b/packages/core/src/components/button/abstractButton.tsx @@ -15,6 +15,13 @@ import { safeInvoke } from "../../common/utils"; import { Spinner } from "../spinner/spinner"; export interface IButtonProps extends IActionProps { + /** + * If set to `true`, the button will display in an active state. + * This is equivalent to setting `className="pt-active"`. + * @default false + */ + active?: boolean; + /** A ref handler that receives the native HTML element backing this component. */ elementRef?: (ref: HTMLElement) => any; @@ -28,13 +35,6 @@ export interface IButtonProps extends IActionProps { */ loading?: boolean; - /** - * If set to `true`, the button will display in an active state. - * This is equivalent to setting `pt-active` via className. - * @default false - */ - active?: boolean; - /** * HTML `type` attribute of button. Common values are `"button"` and `"submit"`. * Note that this prop has no effect on `AnchorButton`; it only affects `Button`. diff --git a/packages/core/src/components/tag/_common.scss b/packages/core/src/components/tag/_common.scss index 51ea0544804..c3f6556c56d 100644 --- a/packages/core/src/components/tag/_common.scss +++ b/packages/core/src/components/tag/_common.scss @@ -36,6 +36,10 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default; &.pt-tag-removable { padding-right: $tag-height; } + + &.pt-active { + @include focus-outline(0); + } } @mixin pt-tag-large() { diff --git a/packages/core/src/components/tag/tag.tsx b/packages/core/src/components/tag/tag.tsx index b5bc72bb8f3..7b248b05030 100644 --- a/packages/core/src/components/tag/tag.tsx +++ b/packages/core/src/components/tag/tag.tsx @@ -14,12 +14,19 @@ import { isFunction } from "../../common/utils"; import * as Classes from "../../common/classes"; -export interface ITagProps extends IProps, IIntentProps, React.HTMLProps { +export interface ITagProps extends IProps, IIntentProps, React.HTMLAttributes { + /** + * If set to `true`, the tag will display in an active state. + * This is equivalent to setting `className="pt-active"`. + * @default false + */ + active?: boolean; + /** * Click handler for remove button. * Button will only be rendered if this prop is defined. */ - onRemove?: (e: React.MouseEvent) => void; + onRemove?: (e: React.MouseEvent) => void; } @PureRender @@ -27,12 +34,14 @@ export class Tag extends React.Component { public static displayName = "Blueprint.Tag"; public render() { - const { className, intent, onRemove } = this.props; + const { active, className, intent, onRemove } = this.props; const tagClasses = classNames(Classes.TAG, Classes.intentClass(intent), { [Classes.TAG_REMOVABLE]: onRemove != null, + [Classes.ACTIVE]: active, }, className); - const button = - isFunction(onRemove) ?