Skip to content

Commit

Permalink
fix: add anchor element attribute types to Button (carbon-design-syst…
Browse files Browse the repository at this point in the history
…em#18598)

* fix: add anchor element attribute types to Button

* fix: update public api
  • Loading branch information
adamalston authored Feb 18, 2025
1 parent 9d0c15e commit 73c1439
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ Map {
"onMouseLeave": Object {
"type": "func",
},
"rel": Object {
"type": "string",
},
"renderIcon": Object {
"args": Array [
Array [
Expand Down Expand Up @@ -470,6 +473,9 @@ Map {
"tabIndex": Object {
"type": "number",
},
"target": Object {
"type": "string",
},
"tooltipAlignment": Object {
"args": Array [
Array [
Expand Down
22 changes: 21 additions & 1 deletion packages/react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface ButtonBaseProps
/**
* Optionally specify an href for your Button to become an `<a>` element
*/
href?: string;
href?: React.AnchorHTMLAttributes<HTMLAnchorElement>['href'];

/**
* If specifying the `renderIcon` prop, provide a description for that icon that can
Expand All @@ -82,6 +82,11 @@ export interface ButtonBaseProps
? IconButtonKind
: ButtonKind;

/**
* Optionally specify a `rel` when using an `<a>` element.
*/
rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];

/**
* Optional prop to allow overriding the icon rendering.
* Can be a React component class
Expand All @@ -93,6 +98,11 @@ export interface ButtonBaseProps
*/
size?: ButtonSize;

/**
* Optionally specify a `target` when using an `<a>` element.
*/
target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];

/**
* Specify the alignment of the tooltip to the icon-only button.
* Can be one of: start, center, or end.
Expand Down Expand Up @@ -328,6 +338,11 @@ const Button: ButtonComponent = React.forwardRef(
*/
onMouseLeave: PropTypes.func,

/**
* Optionally specify a `rel` when using an `<a>` element.
*/
rel: PropTypes.string,

/**
* Optional prop to allow overriding the icon rendering.
* Can be a React component class
Expand All @@ -349,6 +364,11 @@ const Button: ButtonComponent = React.forwardRef(
*/
tabIndex: PropTypes.number,

/**
* Optionally specify a `target` when using an `<a>` element.
*/
target: PropTypes.string,

/**
* Specify the alignment of the tooltip to the icon-only button.
* Can be one of: start, center, or end.
Expand Down

0 comments on commit 73c1439

Please sign in to comment.