Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

Commit

Permalink
fix(Pill): Make Pill close button a type of button instead of submit (#…
Browse files Browse the repository at this point in the history
…625)

BREAKING CHANGE: If you need the close button of the `Pill` to be of `type` `submit`, you can pass
it a `buttonType` like so <Pill buttonType="submit"/>
  • Loading branch information
chardos authored May 21, 2019
1 parent a605d10 commit ef877cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions react/Pill/Pill.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ScreenReaderOnly from '../ScreenReaderOnly/ScreenReaderOnly';

type Props = {
children?: React$Node,
buttonType?: string,
text?: React$Node,
onClose?: Function,
className?: string
Expand Down Expand Up @@ -39,7 +40,14 @@ export default class Pill extends Component<Props> {
}

renderInteractivePill() {
const { children, text, onClose, className, ...restProps } = this.props;
const {
children,
text,
onClose,
buttonType = 'button',
className,
...restProps
} = this.props;
const content = children || text;

return (
Expand All @@ -50,7 +58,11 @@ export default class Pill extends Component<Props> {
<Text baseline={false} raw>
{content}
</Text>
<button className={styles.removeButton} onClick={onClose}>
<button
type={buttonType}
className={styles.removeButton}
onClick={onClose}
>
<ScreenReaderOnly>Remove item {content}</ScreenReaderOnly>
<div className={styles.removeCircle}>
<CrossIcon
Expand Down
3 changes: 3 additions & 0 deletions react/Pill/__snapshots__/Pill.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ exports[`Pill: should render an additional class for the interactive pill 1`] =
<button
className="Pill__removeButton"
onClick={[Function]}
type="button"
>
<ScreenReaderOnly
component="span"
Expand Down Expand Up @@ -98,6 +99,7 @@ exports[`Pill: should render an interactive pill 1`] = `
<button
className="Pill__removeButton"
onClick={[Function]}
type="button"
>
<ScreenReaderOnly
component="span"
Expand Down Expand Up @@ -130,6 +132,7 @@ exports[`Pill: should render an interactive pill with the legacy "text" prop 1`]
<button
className="Pill__removeButton"
onClick={[Function]}
type="button"
>
<ScreenReaderOnly
component="span"
Expand Down

0 comments on commit ef877cd

Please sign in to comment.