Skip to content

Commit a63a847

Browse files
authored
button: remove extra button wrap (#87276)
Tooltip with disabled skips rendering and just renders children
1 parent 16f6130 commit a63a847

File tree

2 files changed

+34
-42
lines changed

2 files changed

+34
-42
lines changed

static/app/components/core/button/index.tsx

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -283,47 +283,39 @@ function BaseButton({
283283
// Buttons come in 4 flavors: <Link>, <ExternalLink>, <a>, and <button>.
284284
// Let's use props to determine which to serve up, so we don't have to think about it.
285285
// *Note* you must still handle tabindex manually.
286-
const button = (
287-
<StyledButton
288-
aria-label={accessibleLabel}
289-
aria-disabled={disabled}
290-
busy={busy}
291-
disabled={disabled}
292-
to={disabled ? undefined : to}
293-
href={disabled ? undefined : href}
294-
replace={replace}
295-
size={size}
296-
priority={priority}
297-
borderless={borderless}
298-
translucentBorder={translucentBorder}
299-
type={type}
300-
{...buttonProps}
301-
onClick={handleClick}
302-
role="button"
303-
>
304-
{priority !== 'link' && (
305-
<InteractionStateLayer
306-
higherOpacity={priority && ['primary', 'danger'].includes(priority)}
307-
/>
308-
)}
309-
<ButtonLabel size={size} borderless={borderless}>
310-
{icon && (
311-
<Icon size={size} hasChildren={hasChildren}>
312-
<IconDefaultsProvider size={ICON_SIZES[size]}>{icon}</IconDefaultsProvider>
313-
</Icon>
314-
)}
315-
{children}
316-
</ButtonLabel>
317-
</StyledButton>
318-
);
319-
320-
if (!title) {
321-
return button;
322-
}
323-
324286
return (
325-
<Tooltip skipWrapper {...tooltipProps} title={title}>
326-
{button}
287+
<Tooltip skipWrapper {...tooltipProps} title={title} disabled={!title}>
288+
<StyledButton
289+
aria-label={accessibleLabel}
290+
aria-disabled={disabled}
291+
busy={busy}
292+
disabled={disabled}
293+
to={disabled ? undefined : to}
294+
href={disabled ? undefined : href}
295+
replace={replace}
296+
size={size}
297+
priority={priority}
298+
borderless={borderless}
299+
translucentBorder={translucentBorder}
300+
type={type}
301+
{...buttonProps}
302+
onClick={handleClick}
303+
role="button"
304+
>
305+
{priority !== 'link' && (
306+
<InteractionStateLayer
307+
higherOpacity={priority && ['primary', 'danger'].includes(priority)}
308+
/>
309+
)}
310+
<ButtonLabel size={size} borderless={borderless}>
311+
{icon && (
312+
<Icon size={size} hasChildren={hasChildren}>
313+
<IconDefaultsProvider size={ICON_SIZES[size]}>{icon}</IconDefaultsProvider>
314+
</Icon>
315+
)}
316+
{children}
317+
</ButtonLabel>
318+
</StyledButton>
327319
</Tooltip>
328320
);
329321
}

static/app/components/tooltip.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ function Tooltip({
6666

6767
// Reset the visibility when the tooltip becomes disabled
6868
useEffect(() => {
69-
if (disabled) {
69+
if (disabled && isOpen) {
7070
reset();
7171
}
72-
}, [reset, disabled]);
72+
}, [reset, disabled, isOpen]);
7373

7474
// Update the tooltip when the tooltip is forced to be visible and the children change
7575
useEffect(() => {

0 commit comments

Comments
 (0)