Skip to content

Commit

Permalink
Use separate TreeGridItem for mover arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Jun 8, 2020
1 parent b5932a4 commit 69a1fd5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 25 deletions.
53 changes: 31 additions & 22 deletions packages/block-editor/src/components/block-navigation/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { __experimentalTreeGridCell as TreeGridCell } from '@wordpress/components';
import {
__experimentalTreeGridCell as TreeGridCell,
__experimentalTreeGridItem as TreeGridItem,
} from '@wordpress/components';

import { moreVertical } from '@wordpress/icons';
import { useState } from '@wordpress/element';

Expand Down Expand Up @@ -96,27 +100,32 @@ export default function BlockNavigationBlock( {
</TreeGridCell>
{ hasRenderedMovers && (
<>
<TreeGridCell className={ moverCellClassName }>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverUpButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
</TreeGridCell>
<TreeGridCell className={ moverCellClassName }>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverDownButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
<TreeGridCell
className={ moverCellClassName }
withoutGridItem
>
<TreeGridItem>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverUpButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
</TreeGridItem>
<TreeGridItem>
{ ( { ref, tabIndex, onFocus } ) => (
<BlockMoverDownButton
__experimentalOrientation="vertical"
clientIds={ [ clientId ] }
ref={ ref }
tabIndex={ tabIndex }
onFocus={ onFocus }
/>
) }
</TreeGridItem>
</TreeGridCell>
</>
) }
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export {
default as __experimentalTreeGrid,
TreeGridRow as __experimentalTreeGridRow,
TreeGridCell as __experimentalTreeGridCell,
TreeGridItem as __experimentalTreeGridItem,
} from './tree-grid';
export { default as TreeSelect } from './tree-select';
export { default as __experimentalUnitControl } from './unit-control';
Expand Down
14 changes: 11 additions & 3 deletions packages/components/src/tree-grid/cell.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
/**
* Internal dependencies
*/
import RovingTabIndexItem from './roving-tab-index-item';
import TreeGridItem from './item';

export default function TreeGridCell( { children, ...props } ) {
export default function TreeGridCell( {
children,
withoutGridItem = false,
...props
} ) {
return (
<td { ...props } role="gridcell">
<RovingTabIndexItem>{ children }</RovingTabIndexItem>
{ withoutGridItem ? (
children
) : (
<TreeGridItem>{ children }</TreeGridItem>
) }
</td>
);
}
1 change: 1 addition & 0 deletions packages/components/src/tree-grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ export default function TreeGrid( { children, ...props } ) {

export { default as TreeGridRow } from './row';
export { default as TreeGridCell } from './cell';
export { default as TreeGridItem } from './item';
8 changes: 8 additions & 0 deletions packages/components/src/tree-grid/item.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Internal dependencies
*/
import RovingTabIndexItem from './roving-tab-index-item';

export default function TreeGridItem( { children, ...props } ) {
return <RovingTabIndexItem { ...props }>{ children }</RovingTabIndexItem>;
}

0 comments on commit 69a1fd5

Please sign in to comment.