-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(s2): apply styling to CardView when using an action bar #7795
Conversation
// Add padding at the bottom when the action bar is visible so users can scroll to the last items. | ||
// Also add scroll padding so keyboard navigating preserves the padding. | ||
paddingBottom: actionBarHeight > 0 ? actionBarHeight + options.minSpace.height : 0, | ||
scrollPadding: options.minSpace.height, | ||
scrollPaddingBottom: actionBarHeight + options.minSpace.height | ||
}} | ||
className={renderProps => UNSAFE_className + cardViewStyles({...renderProps, isLoading: props.loadingState === 'loading'}, styles)}> | ||
className={renderProps => (!props.renderActionBar ? UNSAFE_className + cardViewStyles({...renderProps, isLoading: props.loadingState === 'loading'}, styles) : '')}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is right, I think you still want cardViewStyles with all the states it comes with
className={renderProps => (!props.renderActionBar ? UNSAFE_className + cardViewStyles({...renderProps, isLoading: props.loadingState === 'loading'}, styles) : '')}> | |
className={renderProps => (!props.renderActionBar ? UNSAFE_className + cardViewStyles({...renderProps, isLoading: props.loadingState === 'loading'}, styles) : cardViewStyles({...renderProps, isLoading: props.loadingState === 'loading'}))}> |
but you don't want either of the ways to overrides styles as provided by the user
@@ -262,7 +263,7 @@ export const CardView = /*#__PURE__*/ (forwardRef as forwardRefType)(function Ca | |||
// ActionBar cannot be inside the GridList due to ARIA and focus management requirements. | |||
if (props.renderActionBar) { | |||
return ( | |||
<div ref={domRef} className={style({position: 'relative', overflow: 'clip', size: 'fit'})}> | |||
<div ref={domRef} className={UNSAFE_className + mergeStyles(style({position: 'relative', overflow: 'clip', size: 'fit'}), styles)} style={UNSAFE_style}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you still want to do a safe merge of styles with allowed overrides, so you may want to pull out this style
like the other overridable ones style(..., getAllowedOverrides({height: true}))
## API Changes
react-aria-components/react-aria-components:Menu Menu <T extends {}> {
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children?: ReactNode | ({}) => ReactNode
- className?: string | ((MenuRenderProps & {
- defaultClassName: string | undefined
-})) => string
+ className?: string
defaultSelectedKeys?: 'all' | Iterable<Key>
dependencies?: ReadonlyArray<any>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
- renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
slot?: string | null
- style?: CSSProperties | ((MenuRenderProps & {
- defaultStyle: CSSProperties
-})) => CSSProperties | undefined
+ style?: CSSProperties
} /react-aria-components:MenuProps MenuProps <T> {
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children?: ReactNode | (T) => ReactNode
- className?: string | ((MenuRenderProps & {
- defaultClassName: string | undefined
-})) => string
+ className?: string
defaultSelectedKeys?: 'all' | Iterable<Key>
dependencies?: ReadonlyArray<any>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
- renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
slot?: string | null
- style?: CSSProperties | ((MenuRenderProps & {
- defaultStyle: CSSProperties
-})) => CSSProperties | undefined
+ style?: CSSProperties
} /react-aria-components:NumberFieldRenderProps NumberFieldRenderProps {
isDisabled: boolean
isInvalid: boolean
- isRequired: boolean
state: NumberFieldState
} @react-spectrum/s2/@react-spectrum/s2:Menu Menu <T extends {}> {
UNSAFE_className?: string
UNSAFE_style?: CSSProperties
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children: ReactNode | ({}) => ReactNode
defaultSelectedKeys?: 'all' | Iterable<Key>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
hideLinkOutIcon?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
- renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
size?: 'S' | 'M' | 'L' | 'XL' = 'M'
styles?: StylesProp
} /@react-spectrum/s2:TreeViewItem-TreeViewItem {
+TreeViewItem <T extends {}> {
aria-label?: string
+ childItems?: Iterable<{}>
children: ReactNode
download?: boolean | string
hasChildItems?: boolean
href?: Href
id?: Key
isDisabled?: boolean
onAction?: () => void
onHoverChange?: (boolean) => void
onHoverEnd?: (HoverEvent) => void
onHoverStart?: (HoverEvent) => void
ping?: string
referrerPolicy?: HTMLAttributeReferrerPolicy
rel?: string
routerOptions?: RouterOptions
target?: HTMLAttributeAnchorTarget
textValue: string
value?: T
} /@react-spectrum/s2:MenuProps MenuProps <T> {
UNSAFE_className?: string
UNSAFE_style?: CSSProperties
aria-describedby?: string
aria-details?: string
aria-label?: string
aria-labelledby?: string
autoFocus?: boolean | FocusStrategy
children: ReactNode | (T) => ReactNode
defaultSelectedKeys?: 'all' | Iterable<Key>
disabledKeys?: Iterable<Key>
disallowEmptySelection?: boolean
hideLinkOutIcon?: boolean
id?: string
items?: Iterable<T>
onAction?: (Key) => void
onClose?: () => void
onScroll?: (UIEvent<Element>) => void
onSelectionChange?: (Selection) => void
- renderEmptyState?: () => ReactNode
selectedKeys?: 'all' | Iterable<Key>
selectionMode?: SelectionMode
shouldFocusWrap?: boolean
size?: 'S' | 'M' | 'L' | 'XL' = 'M'
styles?: StylesProp
} /@react-spectrum/s2:TreeViewItemProps-TreeViewItemProps {
+TreeViewItemProps <T extends {} = {}> {
aria-label?: string
+ childItems?: Iterable<{}>
children: ReactNode
download?: boolean | string
hasChildItems?: boolean
href?: Href
id?: Key
isDisabled?: boolean
onAction?: () => void
onHoverChange?: (boolean) => void
onHoverEnd?: (HoverEvent) => void
onHoverStart?: (HoverEvent) => void
ping?: string
referrerPolicy?: HTMLAttributeReferrerPolicy
rel?: string
routerOptions?: RouterOptions
target?: HTMLAttributeAnchorTarget
textValue: string
value?: T
} @react-spectrum/style-macro-s1/@react-spectrum/style-macro-s1:focusRing-focusRing {
- returnVal: undefined
-} @react-spectrum/tree/@react-spectrum/tree:TreeViewItem-TreeViewItem {
+TreeViewItem <T extends {}> {
aria-label?: string
+ childItems?: Iterable<{}>
children: ReactNode
download?: boolean | string
hasChildItems?: boolean
href?: Href
id?: Key
isDisabled?: boolean
onAction?: () => void
ping?: string
referrerPolicy?: HTMLAttributeReferrerPolicy
rel?: string
routerOptions?: RouterOptions
target?: HTMLAttributeAnchorTarget
textValue: string
} /@react-spectrum/tree:SpectrumTreeViewItemProps-SpectrumTreeViewItemProps {
+SpectrumTreeViewItemProps <T extends {} = {}> {
aria-label?: string
+ childItems?: Iterable<{}>
children: ReactNode
download?: boolean | string
hasChildItems?: boolean
href?: Href
id?: Key
isDisabled?: boolean
onAction?: () => void
ping?: string
referrerPolicy?: HTMLAttributeReferrerPolicy
rel?: string
routerOptions?: RouterOptions
target?: HTMLAttributeAnchorTarget
textValue: string
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but would be nice to have a story that applies styles to a CardView when an actionbar is provided just to make testing easier. I tested locally and didn't realize that the ActionBar's CardView doesn't actually use the styles provided and thought it wasn't working haha
* fix(s2): apply styling to cardview when using an action bar * remove comment * don't apply styles twice * add styles back in * fixes from review
Closes #7684
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: