-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TreeGrid: Convert to TypeScript (#47516)
* TreeGridRow: Convert to TypeScript * Add types for roving tab index * Actually throw if context is undefined * TreeGridItem: Add types * TreeGridCell: Add types * TreeGrid: Add types * Fixup * Convert stories * Convert tests * Exclude from tsconfig * Improve prop description for `withoutGridItem` * Simply focusable element type * Remove unnecessary eslint-disable * Tweak aria types * Update readme * Add changelog * Change confusing story * Shift all possible `Element`s to `HTMLElement`
- Loading branch information
Showing
28 changed files
with
609 additions
and
333 deletions.
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { forwardRef } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import TreeGridItem from './item'; | ||
import type { WordPressComponentProps } from '../ui/context'; | ||
import type { TreeGridCellProps } from './types'; | ||
|
||
function UnforwardedTreeGridCell( | ||
{ | ||
children, | ||
withoutGridItem = false, | ||
...props | ||
}: WordPressComponentProps< TreeGridCellProps, 'td', false >, | ||
ref: React.ForwardedRef< any > | ||
) { | ||
return ( | ||
<td { ...props } role="gridcell"> | ||
{ withoutGridItem ? ( | ||
<>{ children }</> | ||
) : ( | ||
<TreeGridItem ref={ ref }>{ children }</TreeGridItem> | ||
) } | ||
</td> | ||
); | ||
} | ||
|
||
/** | ||
* `TreeGridCell` is used to create a tree hierarchy. | ||
* It is not a visually styled component, but instead helps with adding | ||
* keyboard navigation and roving tab index behaviors to tree grid structures. | ||
* | ||
* @see {@link https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html} | ||
*/ | ||
export const TreeGridCell = forwardRef( UnforwardedTreeGridCell ); | ||
|
||
export default TreeGridCell; |
Oops, something went wrong.
464426a
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.
Flaky tests detected in 464426a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4084174285
📝 Reported issues:
specs/editor/blocks/query.test.js
specs/editor/various/multi-block-selection.test.js