Skip to content

Commit

Permalink
Add optional custom tooltip text
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Aug 1, 2022
1 parent f3a5369 commit a858d70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/components/src/input-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function UnforwardedInputControl(
onKeyDown = noop,
prefix,
showTooltip = false,
tooltipText: tooltipTextProp,
size = 'default',
suffix,
value,
Expand All @@ -77,7 +78,9 @@ export function UnforwardedInputControl(
onChange,
} );

const tooltipText = typeof label === 'string' ? label : undefined;
const tooltipText =
tooltipTextProp ||
( typeof label === 'string' ? ( label as string ) : undefined );

return (
<InputBase
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/input-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export interface InputFieldProps extends BaseProps {
*/
showTooltip?: boolean;
stateReducer?: StateReducer;
/**
* Custom text to display when tooltips are enabled. If not provided enabled
* tooltips will fallback to using the label value.
*/
tooltipText?: string;
/**
* The current value of the input.
*/
Expand Down

0 comments on commit a858d70

Please sign in to comment.