Skip to content

Commit

Permalink
fix: add autoalign in button (#17723)
Browse files Browse the repository at this point in the history
Co-authored-by: Alison Joseph <alison.joseph@us.ibm.com>
  • Loading branch information
preetibansalui and alisonjoseph authored Oct 11, 2024
1 parent 261d33c commit a71040f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ Map {
],
"type": "oneOfType",
},
"autoAlign": Object {
"type": "bool",
},
"children": Object {
"type": "node",
},
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const Button = React.forwardRef(function Button<T extends React.ElementType>(
const tooltipRef = useRef(null);
const {
as,
autoAlign = false,
children,
hasIconOnly = false,
iconDescription,
Expand Down Expand Up @@ -191,6 +192,7 @@ const Button = React.forwardRef(function Button<T extends React.ElementType>(
onMouseLeave={onMouseLeave}
onFocus={onFocus}
onBlur={onBlur}
autoAlign={autoAlign}
onClick={composeEventHandlers([onClick, handleClick])}
renderIcon={iconOnlyImage ? null : ButtonImageElement} // avoid doubling the icon.
>
Expand All @@ -212,6 +214,11 @@ Button.propTypes = {
PropTypes.elementType,
]),

/**
* **Experimental**: Will attempt to automatically align the tooltip
*/
autoAlign: PropTypes.bool,

/**
* Specify the content of your Button
*/
Expand Down

0 comments on commit a71040f

Please sign in to comment.