feat: Add TableFooter component#9943
Conversation
| id={id} | ||
| dependencies={[...dependencies, columns]} | ||
| isDisabled={isInFooter} | ||
| disabledBehavior="selection" |
There was a problem hiding this comment.
New feature: support for disabledBehavior at the individual Row level, not just at the Table level. This is so that the summary rows are not selectable but still focusable, regardless of the disabledBehavior of the rest of the table. Is this something we want to support?
There was a problem hiding this comment.
I guess its fine, but feels a bit iffy to me to make it public api if it really is only used for the summary row case. Could we not just do a private prop or context or somethingto set this?
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
| ); | ||
| }; | ||
|
|
||
| export const TableSectionDnd: TableStory = (args) => { |
There was a problem hiding this comment.
I'm unable to drop at the end of a given section. I also cannot drop into an empty section
There was a problem hiding this comment.
for some reason, in Chrome , each drag takes me two mouse clicks to initiate, I doubt that was caused by this PR, so just noting it
There was a problem hiding this comment.
I was trying to keep this PR simple. 😅 It was not my intent to work on drag and drop here but you asked for an example so I added one. The issue you mention is pre-existing: you can't drop before a disabled items (like the section headers). We should handle that separately.
There was a problem hiding this comment.
yeah, not going to hold anything up with it, all good
There was a problem hiding this comment.
I also noticed that just keyboard navigating up and down/through a row's elements in this table also causes keyboard focus to get stuck on the drag handle, just something to also track
| id={id} | ||
| dependencies={[...dependencies, columns]} | ||
| isDisabled={isInFooter} | ||
| disabledBehavior="selection" |
There was a problem hiding this comment.
I guess its fine, but feels a bit iffy to me to make it public api if it really is only used for the summary row case. Could we not just do a private prop or context or somethingto set this?
| ); | ||
| }; | ||
|
|
||
| export const TableSectionDnd: TableStory = (args) => { |
There was a problem hiding this comment.
I also noticed that just keyboard navigating up and down/through a row's elements in this table also causes keyboard focus to get stuck on the drag handle, just something to also track
|
Build successful! 🎉 |
| * The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. | ||
| * @default 'react-aria-TableFooter' | ||
| */ | ||
| className?: string |
There was a problem hiding this comment.
why not renderProps enabled? I guess it's non-breaking to add it in the future
There was a problem hiding this comment.
because there aren't any states
There was a problem hiding this comment.
well, there aren't any states yet, but TableBody has isEmpty and isDropTarget. Which, maybe empty makes sense and drop target doesn't. Could also include id on both of them
| </Row> | ||
| )} | ||
| </TableBody> | ||
| <TableFooter> |
There was a problem hiding this comment.
I checked and multiple footer rows appears to work, though row divider borders aren't a good contrast. I tried nesting rows in the footer as well in case someone wanted to use progressive disclosure for more complicated summaries, that also worked, though the expansion could end up in an odd spot, I made it the title column here.
I'm assuming these aren't officially supported, but nice to know they won't be much trouble to eventually support. Though it might be nice to be able to tell a TableBody/Footer if it is expandable so that the alignment doesn't end up like this if only one of them actually has expansion. I don't think we're doing anything right now that would prevent that in the future though.
|
Build successful! 🎉 |
## API Changes
react-aria-components/react-aria-components:Row Row <T extends {}> {
children?: ReactNode | ({}) => ReactElement
className?: ClassNameOrFunction<RowRenderProps> = 'react-aria-Row'
columns?: Iterable<{}>
dependencies?: ReadonlyArray<any>
+ disabledBehavior?: DisabledBehavior
download?: boolean | string
hasChildItems?: boolean
href?: Href
hrefLang?: string
isDisabled?: boolean
onAction?: () => void
onClick?: (MouseEvent<FocusableElement>) => void
onHoverChange?: (boolean) => void
onHoverEnd?: (HoverEvent) => void
onHoverStart?: (HoverEvent) => void
onPress?: (PressEvent) => void
onPressChange?: (boolean) => void
onPressEnd?: (PressEvent) => void
onPressStart?: (PressEvent) => void
onPressUp?: (PressEvent) => void
ping?: string
referrerPolicy?: HTMLAttributeReferrerPolicy
rel?: string
render?: DOMRenderFunction<keyof React.JSX.IntrinsicElements, RowRenderProps>
routerOptions?: RouterOptions
style?: StyleOrFunction<RowRenderProps>
target?: HTMLAttributeAnchorTarget
textValue?: string
value?: {}
}/react-aria-components:RowProps RowProps <T> {
children?: ReactNode | (T) => ReactElement
className?: ClassNameOrFunction<RowRenderProps> = 'react-aria-Row'
columns?: Iterable<T>
dependencies?: ReadonlyArray<any>
+ disabledBehavior?: DisabledBehavior
download?: boolean | string
hasChildItems?: boolean
href?: Href
hrefLang?: string
isDisabled?: boolean
onAction?: () => void
onClick?: (MouseEvent<FocusableElement>) => void
onHoverChange?: (boolean) => void
onHoverEnd?: (HoverEvent) => void
onHoverStart?: (HoverEvent) => void
onPress?: (PressEvent) => void
onPressChange?: (boolean) => void
onPressEnd?: (PressEvent) => void
onPressStart?: (PressEvent) => void
onPressUp?: (PressEvent) => void
ping?: string
referrerPolicy?: HTMLAttributeReferrerPolicy
rel?: string
render?: DOMRenderFunction<keyof React.JSX.IntrinsicElements, RowRenderProps>
routerOptions?: RouterOptions
style?: StyleOrFunction<RowRenderProps>
target?: HTMLAttributeAnchorTarget
textValue?: string
value?: T
}/react-aria-components:TableFooter+TableFooter <T extends {}> {
+ children?: ReactNode | (T) => ReactNode
+ className?: string = 'react-aria-TableFooter'
+ dependencies?: ReadonlyArray<any>
+ items?: Iterable<T>
+ style?: CSSProperties
+}/react-aria-components:TableFooterProps+TableFooterProps <T> {
+ children?: ReactNode | (T) => ReactNode
+ className?: string = 'react-aria-TableFooter'
+ dependencies?: ReadonlyArray<any>
+ items?: Iterable<T>
+ style?: CSSProperties
+}@react-spectrum/s2/@react-spectrum/s2:TableFooter+TableFooter <T extends {}> {
+ children?: ReactNode | (T) => ReactNode
+ dependencies?: ReadonlyArray<any>
+ items?: Iterable<T>
+}/@react-spectrum/s2:TableFooterProps+TableFooterProps <T> {
+ children?: ReactNode | (T) => ReactNode
+ dependencies?: ReadonlyArray<any>
+ items?: Iterable<T>
+} |
Closes #4372, closes #7312
Adds a new
<TableFooter>component to React Aria and S2, which may contain one or more rows. When rendered as an HTML table, this is a<tfoot>element, otherwise it hasrole="rowgroup".It also allows rendering multiple
<TableBody>elements, which enables sections to be implemented.