-
Notifications
You must be signed in to change notification settings - Fork 1.3k
S2 table #6778
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
S2 table #6778
Conversation
row focus ring needs row render function first
this will need changes to RAC table as well....
…utton focus visible also tested moving the sort descriptor in front of the column text andwithout reserving room
…r drag/checkbox columns
…sizers are skipped
| } | ||
|
|
||
| // TODO: Note that loadMore and loadingState are now on the Table instead of on the TableBody | ||
| export interface TableProps extends Omit<RACTableProps, 'style' | 'disabledBehavior' | 'className' | 'onRowAction' | 'selectionBehavior' | 'onScroll' | 'onCellAction' | 'dragAndDropHooks'>, StyleProps, S2TableProps { |
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.
Since table allows overriding the height, we should extends UnsafeStyles here and add styles using StylesPropWithHeight.
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.
good call, I'm not sure why it didn't complain in story where I make use of both height and width via styles hmm
| <InternalTableContext.Provider value={context}> | ||
| <RACTable | ||
| ref={scrollRef} | ||
| style={{WebkitTransform: 'translateZ(0)'}} |
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.
only webkit? What is this fixing?
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.
| let loadMoreSpinner = ( | ||
| <UNSTABLE_TableLoadingIndicator className={style({height: 'full', width: 'full'})}> | ||
| <div className={centeredWrapper}> | ||
| <ProgressCircle |
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.
well we should probably ask spectrum. I still think smaller is better, or maybe it should depend on the density.
| <Collection items={items}> | ||
| {children} | ||
| </Collection> | ||
| {loadingState === 'loadingMore' && [...items].length > 0 && loadMoreSpinner} |
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.
Why the length check here but not below? I'd be a little concerned about performance of the spread as well so if we can avoid it that would be good.
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.
We should probably also discuss how table should support ghost loading at some point, and what the default should be.
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.
the length check here is to prevent a situation where somehow the `loadingState = "loadingMore"' but no items are actually loaded aka the below:

For loadingState = "loading" we don't need these checks because the rendering of that circle/empty state is provided to renderEmptyState instead so RAC table handles rendering it only when the collection size is 0.
We could consider the "loadingMore" case a user error and get rid of the length check perhaps, what do you think? Otherwise I need some way of knowing the collection is empty...
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.
Hmm yeah I'd consider that programmer error I think
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.
sounds good, removed the check
|
|
||
| function CellFocusRing(props: {isFocusVisible: boolean}) { | ||
| let {isFocusVisible} = props; | ||
| return <div role="presentation" style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}} className={style({...cellFocus})({isFocusVisible})} />; |
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.
| return <div role="presentation" style={{position: 'absolute', top: 0, left: 0, bottom: 0, right: 0}} className={style({...cellFocus})({isFocusVisible})} />; | |
| return <div role="presentation" style={{position: 'absolute', inset: 0}} className={style({...cellFocus})({isFocusVisible})} />; |
Or actually, why are the position properties inline instead of in the style macro?
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.
ah it previously was but the cellFocus gets reused in other places so I put this inline to ensure it didn't propagate elsewhere unexpectedly. I dunno why I didn't put it in the style macro in the className, whoops will do thanks!
| insetEnd: size(-6), | ||
| cursor: { | ||
| default: 'none', | ||
| resizableDirection: { |
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.
Eventually we need our custom cursors here like we had in S1?
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.
oh thats right, completely slipped my mind, missed it since I didn't tag it with TODO lol. I'll add it to the followup ticket and see if we need to submit something to the icons team
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.
filed an airtable ticket for those cursors
| // TODO: Need to wait for the menu to fully transition out, otherwise mouse movements may hover the menu items and steal focus from the resizer, | ||
| // causing resizing to end prematurely due to blur. Open to ideas for how to handle this since it affects RAC. Ideally we'd freeze | ||
| // focus from being able to move if we are in resizing mode except if the user clicks away or moves focus with something other than hover | ||
| setTimeout(() => startResize(), 200); |
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.
We could mark popovers/overlays as inert when they are transitioning out maybe
| import {useMediaQuery} from '@react-spectrum/utils'; | ||
|
|
||
| export function useIsMobileDevice(): boolean { | ||
| return useMediaQuery('(max-width: 640px)'); |
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.
Since this is being used to determine the scale, shouldn't it look for @media not ((hover: hover) and (pointer: fine)), which is what the style macro uses for that?
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 considered doing that but I figured we'd want to follow a similar logic style that we had in S1 in preparation for Trays aka we would check screen size. If we use the touch media query that the style macro uses, that would match large screen touch devices right?
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.
But this is being used to determine pixel sizes not whether to show a tray right? The style macro uses the media query I posted to do the same thing, ie scale up dimensions by 25%. Whether to show a tray is indeed based on screen size but that's different from touch scale, which might also occur on large screen devices like iPads or laptops.
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.
ahh right, makes sense, guess I conflated the two. I'll make a separate useScale that uses the media query and use it for table
… doesnt get canceled if the user clicks the resize option and hovers another item while the popover is transitioning out it can cause resizing to be canceled. This prevents that case from happening
… check warning is a compat one for React 19, items check is uneeded due to user error
| user = userEvent.setup({delay: null, pointerMap}); | ||
| }); | ||
| it('provides slots', async () => { | ||
| // Mock console.error for React Canary "Received the string `true` for the boolean attribute `inert`." warning |
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.
So these errors are going to appear in downstream projects tests as well
| slot={props.slot || undefined} | ||
| style={style} | ||
| // @ts-ignore - React < 19 compat | ||
| inert={(isEntering || isExiting) ? 'true' : undefined} |
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.
what is actually the issue?
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 this is causing focus not to move into the popover when it opens now. e.g. try opening the column header menu with a keyboard - focus stays on the header instead of going to the menu item.
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.
Reverted the inert change and used pointer-events: none instead so it only applies to mouse during the exit animation.
# Conflicts: # packages/@react-spectrum/s2/stories/Table.stories.tsx # packages/react-aria-components/test/ComboBox.test.js # packages/react-aria-components/test/Select.test.js
…resizing doesnt get canceled" This reverts commit 9cfb896.
This reverts commit 7006a76. # Conflicts: # packages/react-aria-components/test/ComboBox.test.js # packages/react-aria-components/test/Select.test.js
It has a bunch of internal stuff on it. We don't need the exact height for the resizer, we just need a large enough value that it goes past the end of the table. 100vh should work.
|
I approve! ✅ (GitHub won't let me since I opened the PR 😂) |

See followups that still need to be implemented here: RSP Component Milestones (view)