Skip to content

Commit 2a75be4

Browse files
authored
fix: hide notification badge when button is pending and other pending fixes (#8898)
* fix: hide notification badge when button is pending * fix avatar action button pending layout shift * fix XS size for pending
1 parent abe2e95 commit 2a75be4

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

packages/@react-spectrum/s2/src/ActionButton.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
238238
paddingX: {
239239
default: controlStyle.paddingX,
240240
[avatarOnly]: 0
241+
},
242+
// `control` sets this, but we need to override it for avatar only buttons.
243+
'--iconMargin': {
244+
type: 'marginStart',
245+
value: {
246+
default: fontRelative(-2),
247+
[iconOnly]: 0,
248+
[avatarOnly]: 0
249+
}
241250
}
242251
}, getAllowedOverrides());
243252

@@ -325,10 +334,7 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
325334
[AvatarContext, {
326335
size: avatarSize[size],
327336
styles: style({
328-
marginStart: {
329-
default: '--iconMargin',
330-
':last-child': 0
331-
},
337+
marginStart: '--iconMargin',
332338
flexShrink: 0,
333339
order: 0
334340
})
@@ -345,7 +351,17 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
345351
staticColor: staticColor,
346352
size: props.size === 'XS' ? undefined : props.size,
347353
isDisabled: isDisabled,
348-
styles: style({position: 'absolute', top: '--badgeTop', insetStart: '--badgePosition', marginTop: 'calc((self(height) * -1)/2)', marginStart: 'calc((self(height) * -1)/2)'})
354+
styles: style({
355+
position: 'absolute',
356+
top: '--badgeTop',
357+
insetStart: '--badgePosition',
358+
marginTop: 'calc((self(height) * -1)/2)',
359+
marginStart: 'calc((self(height) * -1)/2)',
360+
opacity: {
361+
default: 1,
362+
isProgressVisible: 0
363+
}
364+
})({isProgressVisible})
349365
}]
350366
]}>
351367
{typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}
@@ -369,6 +385,7 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
369385
styles={style({
370386
size: {
371387
size: {
388+
XS: 12,
372389
S: 14,
373390
M: 18,
374391
L: 20,

packages/@react-spectrum/s2/src/style-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ const allowedOverrides = [
302302
'insetX',
303303
'insetY',
304304
'insetStart',
305-
'insetEnd'
305+
'insetEnd',
306+
'opacity',
307+
'visibility'
306308
] as const;
307309

308310
const widthProperties = [

0 commit comments

Comments
 (0)