@@ -10,7 +10,7 @@ import {Button as RACButton, Provider, TextContext} from 'react-aria-components'
10
10
import { Text } from './Text' ;
11
11
import { SpectrumActionButtonProps } from '@adobe/react-spectrum' ;
12
12
import { tv } from 'tailwind-variants' ;
13
- import { FocusRing , useButton } from 'react-aria' ;
13
+ import { FocusRing , mergeProps , useButton } from 'react-aria' ;
14
14
import React , { CSSProperties , forwardRef , useLayoutEffect , useState } from 'react' ;
15
15
import CornerTriangle from '@spectrum-icons/ui/CornerTriangle' ;
16
16
@@ -29,7 +29,8 @@ export let baseIcon = tv({
29
29
} ) ;
30
30
31
31
let baseButton = tv ( {
32
- base : [ 'box-border flex items-center justify-center border-solid border-none font-[inherit] font-bold cursor-default transition outline-none focus-visible:outline focus-visible:outline-offset disabled:text-disabled' ,
32
+ // need to use outline-0 instead of none because none will show up always in hcm, but need to use outline-none so mouse outline doesn't show up
33
+ base : [ 'box-border flex items-center justify-center border-solid border-none font-[inherit] font-bold cursor-default transition outline-none outline-0 focus-visible:outline focus-visible:outline-offset disabled:text-disabled' ,
33
34
'transform duration pressed:perspective pressed:translate-z-[-2px]' ] ,
34
35
variants : {
35
36
size : {
@@ -42,7 +43,7 @@ let baseButton = tv({
42
43
XL : 'h-c-300 text-300 gap-ttv-100 rounded-[10px]'
43
44
} ,
44
45
isQuiet : {
45
- false : 'bg-tint-100 bg-hover-tint-200' ,
46
+ false : 'bg-tint-100 bg-hover-tint-200' , // don't need to use tint here
46
47
true : 'bg-transparent bg-hover-gray-200' // how to use tint here?
47
48
}
48
49
} ,
@@ -170,7 +171,8 @@ export let staticColorButton = tv({
170
171
171
172
// do forward ref up here so that we get storybook types, at least until someone can figure out why we don't in our
172
173
// normal codebase
173
- let ActionButton = forwardRef ( ( props : SpectrumActionButtonProps & { size ?: 'XS' | 'S' | 'M' | 'L' | 'XL' } , ref : FocusableRef < HTMLElement > ) => {
174
+ // remove onKeyUp from the types so that Storybook auto actions doesn't break press
175
+ let ActionButton = forwardRef ( ( props : Omit < SpectrumActionButtonProps & { size ?: 'XS' | 'S' | 'M' | 'L' | 'XL' } , 'onKeyUp' > , ref : FocusableRef < HTMLElement > ) => {
174
176
props = useSlotProps ( props , 'button' ) ;
175
177
let {
176
178
children,
@@ -190,6 +192,12 @@ let ActionButton = forwardRef((props: SpectrumActionButtonProps & {size?: 'XS' |
190
192
191
193
// how to make sure this stays up to date without calculating
192
194
// while it's already scaled
195
+ // only do during onPress, but that has to wait until we fix the onKeyUp bug OR disable that particular
196
+ let onPress = ( ) => {
197
+ let { width = 0 , height = 0 } = domRef . current ?. getBoundingClientRect ( ) ?? { } ;
198
+ setWidth ( width ) ;
199
+ setHeight ( height ) ;
200
+ } ;
193
201
useLayoutEffect ( ( ) => {
194
202
let { width = 0 , height = 0 } = domRef . current ?. getBoundingClientRect ( ) ?? { } ;
195
203
setWidth ( width ) ;
@@ -199,12 +207,11 @@ let ActionButton = forwardRef((props: SpectrumActionButtonProps & {size?: 'XS' |
199
207
// let styles = hasIcon && !hasLabel ? iconOnlyButton : buttonStyles;
200
208
let styles = staticColor ? staticColorButton : buttonStyles ;
201
209
202
- console . log ( props , styleProps )
203
210
return (
204
211
< FocusRing >
205
212
< RACButton
206
213
{ ...styleProps }
207
- { ...props }
214
+ { ...( mergeProps ( props , { onPress } ) ) }
208
215
ref = { domRef as any }
209
216
data-static-color = { staticColor || undefined }
210
217
data-has-icon = { hasIcon || undefined }
0 commit comments