Skip to content

Commit 501379f

Browse files
authored
Merge branch 'main' into code-connect-ailabel
2 parents 043c2cb + 68799ee commit 501379f

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ Map {
801801
"type": "string",
802802
},
803803
"ariaLabel": [Function],
804+
"autoAlign": Object {
805+
"type": "bool",
806+
},
804807
"children": Object {
805808
"type": "node",
806809
},
@@ -1799,6 +1802,9 @@ Map {
17991802
],
18001803
"type": "oneOf",
18011804
},
1805+
"autoAlign": Object {
1806+
"type": "bool",
1807+
},
18021808
"children": Object {
18031809
"type": "node",
18041810
},
@@ -1836,6 +1842,9 @@ Map {
18361842
],
18371843
"type": "oneOf",
18381844
},
1845+
"autoAlign": Object {
1846+
"type": "bool",
1847+
},
18391848
"className": Object {
18401849
"type": "string",
18411850
},
@@ -4227,6 +4236,9 @@ Map {
42274236
],
42284237
"type": "oneOf",
42294238
},
4239+
"autoAlign": Object {
4240+
"type": "bool",
4241+
},
42304242
"children": Object {
42314243
"type": "node",
42324244
},

packages/react/src/components/CodeSnippet/CodeSnippet.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export interface CodeSnippetProps {
4444
| 'left'
4545
| 'right';
4646

47+
/**
48+
* **Experimental**: Will attempt to automatically align the tooltip
49+
*/
50+
autoAlign?: boolean;
51+
4752
/**
4853
* Specify a label to be read by screen readers on the containing textbox
4954
* node
@@ -150,6 +155,7 @@ export interface CodeSnippetProps {
150155

151156
function CodeSnippet({
152157
align = 'bottom',
158+
autoAlign = false,
153159
className,
154160
type = 'single',
155161
children,
@@ -304,6 +310,7 @@ function CodeSnippet({
304310
<Copy
305311
{...rest}
306312
align={align}
313+
autoAlign={autoAlign}
307314
onClick={handleCopyClick}
308315
aria-label={deprecatedAriaLabel || ariaLabel}
309316
aria-describedby={uid}
@@ -377,6 +384,7 @@ function CodeSnippet({
377384
{!hideCopyButton && (
378385
<CopyButton
379386
align={align}
387+
autoAlign={autoAlign}
380388
size={type === 'multi' ? 'sm' : 'md'}
381389
disabled={disabled}
382390
onClick={handleCopyClick}
@@ -437,6 +445,11 @@ CodeSnippet.propTypes = {
437445
'This prop syntax has been deprecated. Please use the new `aria-label`.'
438446
),
439447

448+
/**
449+
* **Experimental**: Will attempt to automatically align the tooltip
450+
*/
451+
autoAlign: PropTypes.bool,
452+
440453
/**
441454
* Provide the content of your CodeSnippet as a node or string
442455
*/

packages/react/src/components/Copy/Copy.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ interface CopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3535
| 'left'
3636
| 'right';
3737

38+
/**
39+
* **Experimental**: Will attempt to automatically align the tooltip
40+
*/
41+
autoAlign?: boolean;
42+
3843
/**
3944
* Specify an optional className to be applied to the underlying `<button>`
4045
*/
@@ -66,6 +71,7 @@ interface CopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6671

6772
export default function Copy({
6873
align = 'bottom',
74+
autoAlign = false,
6975
children,
7076
className,
7177
feedback = 'Copied!',
@@ -112,6 +118,7 @@ export default function Copy({
112118
<IconButton
113119
closeOnActivation={false}
114120
align={align}
121+
autoAlign={autoAlign}
115122
className={classNames}
116123
label={animation ? feedback : initialLabel}
117124
onClick={composeEventHandlers([onClick, handleClick])}
@@ -143,6 +150,11 @@ Copy.propTypes = {
143150
'right',
144151
]),
145152

153+
/**
154+
* **Experimental**: Will attempt to automatically align the tooltip
155+
*/
156+
autoAlign: PropTypes.bool,
157+
146158
/**
147159
* Pass in content to be rendered in the underlying `<button>`
148160
*/

packages/react/src/components/CopyButton/CopyButton.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export interface CopyButtonProps extends ButtonProps<'button'> {
2929
| 'left'
3030
| 'right';
3131

32+
/**
33+
* **Experimental**: Will attempt to automatically align the tooltip
34+
*/
35+
autoAlign?: boolean;
36+
3237
/**
3338
* Specify an optional className to be applied to the underlying `<button>`
3439
*/
@@ -59,6 +64,7 @@ export interface CopyButtonProps extends ButtonProps<'button'> {
5964
}
6065
export default function CopyButton({
6166
align = 'bottom',
67+
autoAlign = false,
6268
feedback = 'Copied!',
6369
feedbackTimeout = 2000,
6470
iconDescription = 'Copy to clipboard',
@@ -74,6 +80,7 @@ export default function CopyButton({
7480
feedbackTimeout={feedbackTimeout}
7581
onClick={onClick}
7682
align={align}
83+
autoAlign={autoAlign}
7784
className={classnames(className, `${prefix}--copy-btn`)}
7885
aria-label={iconDescription}
7986
{...other}>
@@ -98,6 +105,11 @@ CopyButton.propTypes = {
98105
'right',
99106
]),
100107

108+
/**
109+
* **Experimental**: Will attempt to automatically align the tooltip
110+
*/
111+
autoAlign: PropTypes.bool,
112+
101113
/**
102114
* Specify an optional className to be applied to the underlying `<button>`
103115
*/

packages/react/src/components/IconButton/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ interface IconButtonProps
4141
| 'left'
4242
| 'right';
4343

44+
/**
45+
* **Experimental**: Will attempt to automatically align the tooltip
46+
*/
47+
autoAlign?: boolean;
48+
4449
/**
4550
* Provide an icon or asset to be rendered inside of the IconButton
4651
*/
@@ -109,6 +114,7 @@ interface IconButtonProps
109114
const IconButton = React.forwardRef(function IconButton(
110115
{
111116
align,
117+
autoAlign = false,
112118
children,
113119
className,
114120
closeOnActivation = true,
@@ -134,6 +140,7 @@ const IconButton = React.forwardRef(function IconButton(
134140
return (
135141
<Tooltip
136142
align={align}
143+
autoAlign={autoAlign}
137144
closeOnActivation={closeOnActivation}
138145
className={tooltipClasses}
139146
defaultOpen={defaultOpen}
@@ -178,6 +185,11 @@ IconButton.propTypes = {
178185
'right',
179186
]),
180187

188+
/**
189+
* **Experimental**: Will attempt to automatically align the tooltip
190+
*/
191+
autoAlign: PropTypes.bool,
192+
181193
/**
182194
* Provide an icon or asset to be rendered inside of the IconButton
183195
*/

0 commit comments

Comments
 (0)