Skip to content

Commit 92ce3a4

Browse files
committed
feat: add buttonRef prop
1 parent 701c5cb commit 92ce3a4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/button/src/Button.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import ButtonPresenter from "./presenters/ButtonPresenter";
1414

1515
const Button = (props) => {
1616
const {
17+
buttonRef,
1718
disabled,
1819
icon,
1920
link,
@@ -54,6 +55,7 @@ const Button = (props) => {
5455
onMouseUp: handleMouseUp,
5556
}) => (
5657
<ButtonPresenter
58+
buttonRef={buttonRef}
5759
disabled={disabled}
5860
hasFocus={hasFocus}
5961
hasHover={hasHover}
@@ -89,12 +91,16 @@ Button.defaultProps = {
8991
};
9092

9193
Button.propTypes = {
94+
/**
95+
* A callback ref that gets passed to the HTML button
96+
*/
97+
buttonRef: PropTypes.func,
9298
/**
9399
* Prevents user interaction with the button
94100
*/
95101
disabled: PropTypes.bool,
96102
/**
97-
* A @hig/icon element
103+
* A @weave-design/icon element
98104
*/
99105
icon: PropTypes.node,
100106
/**

packages/button/src/presenters/ButtonPresenter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414

1515
const ButtonPresenter = (props) => {
1616
const {
17+
buttonRef,
1718
disabled,
1819
hasFocus,
1920
hasHover,
@@ -61,6 +62,7 @@ const ButtonPresenter = (props) => {
6162
return (
6263
<Wrapper
6364
{...otherProps}
65+
ref={buttonRef}
6466
className={cx(css(cssStyles.button), className)}
6567
href={href}
6668
tabIndex={tabIndex}
@@ -97,6 +99,7 @@ const ButtonPresenter = (props) => {
9799
ButtonPresenter.displayName = "ButtonPresenter";
98100

99101
ButtonPresenter.propTypes = {
102+
buttonRef: PropTypes.func,
100103
disabled: PropTypes.bool,
101104
hasFocus: PropTypes.bool,
102105
hasHover: PropTypes.bool,

0 commit comments

Comments
 (0)