10
10
* governing permissions and limitations under the License.
11
11
*/
12
12
13
- import { announce } from '@react-aria/live-announcer' ;
14
- import { GridAria , GridProps , useGrid } from '@react-aria/grid' ;
15
- import { gridIds } from './utils' ;
13
+ import { announce } from '@react-aria/live-announcer' ;
14
+ import { GridAria , GridProps , useGrid } from '@react-aria/grid' ;
15
+ import { gridIds } from './utils' ;
16
16
// @ts -ignore
17
17
import intlMessages from '../intl/*.json' ;
18
- import { Layout } from '@react-stately/virtualizer' ;
19
- import { mergeProps , useDescription , useId , useUpdateEffect } from '@react-aria/utils' ;
20
- import { Node } from '@react-types/shared' ;
21
- import { RefObject , useMemo } from 'react' ;
22
- import { TableKeyboardDelegate } from './TableKeyboardDelegate' ;
23
- import { TableState } from '@react-stately/table' ;
24
- import { useCollator , useLocale } from '@react-aria/i18n' ;
25
- import { useLocalizedStringFormatter } from '@react-aria/i18n' ;
18
+ import { Layout } from '@react-stately/virtualizer' ;
19
+ import { mergeProps , useDescription , useId , useUpdateEffect } from '@react-aria/utils' ;
20
+ import { Node } from '@react-types/shared' ;
21
+ import { RefObject , useMemo } from 'react' ;
22
+ import { TableKeyboardDelegate } from './TableKeyboardDelegate' ;
23
+ import { TableState } from '@react-stately/table' ;
24
+ import { useCollator , useLocale } from '@react-aria/i18n' ;
25
+ import { useLocalizedStringFormatter } from '@react-aria/i18n' ;
26
26
27
27
export interface AriaTableProps < T > extends GridProps {
28
28
/** The layout object for the table. Computes what content is visible and how to position and style them. */
@@ -46,8 +46,8 @@ export function useTable<T>(props: AriaTableProps<T>, state: TableState<T>, ref:
46
46
47
47
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
48
48
// When virtualized, the layout object will be passed in as a prop and override this.
49
- let collator = useCollator ( { usage : 'search' , sensitivity : 'base' } ) ;
50
- let { direction} = useLocale ( ) ;
49
+ let collator = useCollator ( { usage : 'search' , sensitivity : 'base' } ) ;
50
+ let { direction } = useLocale ( ) ;
51
51
let disabledBehavior = state . selectionManager . disabledBehavior ;
52
52
let delegate = useMemo ( ( ) => keyboardDelegate || new TableKeyboardDelegate ( {
53
53
collection : state . collection ,
@@ -60,7 +60,7 @@ export function useTable<T>(props: AriaTableProps<T>, state: TableState<T>, ref:
60
60
let id = useId ( props . id ) ;
61
61
gridIds . set ( state , id ) ;
62
62
63
- let { gridProps} = useGrid ( {
63
+ let { gridProps } = useGrid ( {
64
64
...props ,
65
65
id,
66
66
keyboardDelegate : delegate
@@ -69,15 +69,15 @@ export function useTable<T>(props: AriaTableProps<T>, state: TableState<T>, ref:
69
69
// Override to include header rows
70
70
if ( isVirtualized ) {
71
71
// TODO Rob: fix headerRows
72
- gridProps [ 'aria-rowcount' ] = state . collection . size ; // + state.collection.headerRows.length ;
72
+ gridProps [ 'aria-rowcount' ] = state . collection . size + ( state . collection . getItem ( state . collection . head . lastChildKey ) ?. index ?? 0 ) + 1 ;
73
73
}
74
74
75
- let { column, direction : sortDirection } = state . sortDescriptor || { } ;
75
+ let { column, direction : sortDirection } = state . sortDescriptor || { } ;
76
76
let stringFormatter = useLocalizedStringFormatter ( intlMessages ) ;
77
77
let sortDescription = useMemo ( ( ) => {
78
78
let columnName = state . collection . columns . find ( c => c . key === column ) ?. textValue ;
79
- return sortDirection && column ? stringFormatter . format ( `${ sortDirection } Sort` , { columnName} ) : undefined ;
80
- // eslint-disable-next-line react-hooks/exhaustive-deps
79
+ return sortDirection && column ? stringFormatter . format ( `${ sortDirection } Sort` , { columnName } ) : undefined ;
80
+ // eslint-disable-next-line react-hooks/exhaustive-deps
81
81
} , [ sortDirection , column , state . collection . columns ] ) ;
82
82
83
83
let descriptionProps = useDescription ( sortDescription ) ;
0 commit comments