From 7340bf881490d788cc804f36a82f7dca43f9599f Mon Sep 17 00:00:00 2001 From: Preeti Bansal Date: Fri, 11 Oct 2024 17:48:01 +0530 Subject: [PATCH] fix: add autoalign in button --- .../react/__tests__/__snapshots__/PublicAPI-test.js.snap | 3 +++ packages/react/src/components/Button/Button.tsx | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index b7f997ddba64..cc66464392a8 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -395,6 +395,9 @@ Map { ], "type": "oneOfType", }, + "autoAlign": Object { + "type": "bool", + }, "children": Object { "type": "node", }, diff --git a/packages/react/src/components/Button/Button.tsx b/packages/react/src/components/Button/Button.tsx index 5ef1f557c7b9..02cc007c80d1 100644 --- a/packages/react/src/components/Button/Button.tsx +++ b/packages/react/src/components/Button/Button.tsx @@ -130,6 +130,7 @@ const Button = React.forwardRef(function Button( const tooltipRef = useRef(null); const { as, + autoAlign = false, children, hasIconOnly = false, iconDescription, @@ -191,6 +192,7 @@ const Button = React.forwardRef(function Button( onMouseLeave={onMouseLeave} onFocus={onFocus} onBlur={onBlur} + autoAlign={autoAlign} onClick={composeEventHandlers([onClick, handleClick])} renderIcon={iconOnlyImage ? null : ButtonImageElement} // avoid doubling the icon. > @@ -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 */