-
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
Open
yihuiliao
wants to merge
5
commits into
main
Choose a base branch
from
style-cardview
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4
−3
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
970d29e
fix(s2): apply styling to cardview when using an action bar
yihuiliao c8edfb4
remove comment
yihuiliao c6118e3
Merge branch 'main' into style-cardview
yihuiliao bc35675
don't apply styles twice
yihuiliao 3eed5d8
add styles back in
yihuiliao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ import {DOMRef, DOMRefValue, forwardRefType, Key, LoadingState} from '@react-typ | |
import {focusRing, style} from '../style' with {type: 'macro'}; | ||
import {getAllowedOverrides, StylesPropWithHeight, UnsafeStyles} from './style-utils' with {type: 'macro'}; | ||
import {ImageCoordinator} from './ImageCoordinator'; | ||
import {mergeStyles} from '../style/runtime'; | ||
import {Size} from '@react-stately/virtualizer'; | ||
import {useActionBarContainer} from './ActionBar'; | ||
import {useDOMRef} from '@react-spectrum/utils'; | ||
|
@@ -242,14 +243,14 @@ export const CardView = /*#__PURE__*/ (forwardRef as forwardRefType)(function Ca | |
defaultSelectedKeys={undefined} | ||
onSelectionChange={onSelectionChange} | ||
style={{ | ||
...UNSAFE_style, | ||
...(!props.renderActionBar ? UNSAFE_style : {}), | ||
// 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) : '')}> | ||
{children} | ||
</AriaGridList> | ||
</ImageCoordinator> | ||
|
@@ -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}> | ||
snowystinger marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
{cardView} | ||
{actionBar} | ||
</div> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
but you don't want either of the ways to overrides styles as provided by the user