-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: #10121 Implemented the Table Column Header Focus #10369
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
base: main
Are you sure you want to change the base?
Changes from all commits
b1a5f23
5501138
7b609f1
ee5361a
cc36fd3
2c3c225
72c324d
91f777f
cc584d0
c24df2d
67f1451
601e8cc
c429412
91ab937
8924895
97aed7c
648af4b
3ac4e25
7d8e9d8
3354253
5c41b97
fc43fae
a8a21a6
0a24d2a
87a3d2b
2cdc768
72d65a9
5df04e2
22cc255
f54a800
50eede3
906bcd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,15 +11,35 @@ | |||||||
| */ | ||||||||
|
|
||||||||
| import {getChildNodes, getFirstItem} from 'react-stately/private/collections/getChildNodes'; | ||||||||
| import {GridKeyboardDelegate} from '../grid/GridKeyboardDelegate'; | ||||||||
| import {GridKeyboardDelegate, GridKeyboardDelegateOptions} from '../grid/GridKeyboardDelegate'; | ||||||||
| import {ITableCollection} from 'react-stately/private/table/TableCollection'; | ||||||||
| import {Key, Node} from '@react-types/shared'; | ||||||||
|
|
||||||||
| export interface TableKeyboardDelegateOptions<T> extends GridKeyboardDelegateOptions< | ||||||||
| ITableCollection<T> | ||||||||
| > {} | ||||||||
|
|
||||||||
| export class TableKeyboardDelegate<T> extends GridKeyboardDelegate<T, ITableCollection<T>> { | ||||||||
| constructor(options: TableKeyboardDelegateOptions<T>) { | ||||||||
| super(options); | ||||||||
| } | ||||||||
|
|
||||||||
| protected isCell(node: Node<T>): boolean { | ||||||||
| return node.type === 'cell' || node.type === 'rowheader' || node.type === 'column'; | ||||||||
| } | ||||||||
|
|
||||||||
| getFirstKey(fromKey?: Key, global?: boolean, initialFocus?: 'row' | 'columnheader'): Key | null { | ||||||||
|
Member
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. @snowystinger and I have been discussing this a bit and would like to explore some different options. IMO, I think the "initialFocus" option is a bit unclear (just like how global is pretty unclear), maybe it would be good to either have the option declare intent (aka "interaction" where only the first drag and droppable table row key would be returned if "interaction=drag", and the first column would be returned for "interaction=navigation", naming TBD), or to borrow from react-spectrum/packages/react-aria/src/grid/GridKeyboardDelegate.ts Lines 91 to 93 in 4ab7d39
|
||||||||
| if (fromKey == null && initialFocus === 'columnheader') { | ||||||||
| let firstColumn = this.collection.columns.find( | ||||||||
| column => !column.props?.isDragButtonCell && !column.props?.isSelectionCell | ||||||||
| ); | ||||||||
| if (firstColumn) { | ||||||||
| return firstColumn.key; | ||||||||
| } | ||||||||
| } | ||||||||
| return super.getFirstKey(fromKey, global); | ||||||||
| } | ||||||||
|
|
||||||||
| getKeyBelow(key: Key, options?: {includeDisabled?: boolean}): Key | null { | ||||||||
| let startItem = this.collection.getItem(key); | ||||||||
| if (!startItem) { | ||||||||
|
|
@@ -34,7 +54,7 @@ export class TableKeyboardDelegate<T> extends GridKeyboardDelegate<T, ITableColl | |||||||
| return child.key; | ||||||||
| } | ||||||||
|
|
||||||||
| let firstKey = this.getFirstKey(); | ||||||||
| let firstKey = super.getFirstKey(); | ||||||||
| if (firstKey == null) { | ||||||||
| return null; | ||||||||
| } | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.