Skip to content

Commit

Permalink
Expose setIsFullScreen to ref API
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Jan 11, 2022
1 parent d96203d commit 429add8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src-docs/src/views/datagrid/ref.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@ export default () => {
Set cell focus
</EuiButton>
</EuiFlexItem>
<EuiFlexItem>
<EuiButton
size="s"
onClick={() => dataGridRef.current.setIsFullScreen(true)}
>
Set grid to full screen
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer />

Expand Down
1 change: 1 addition & 0 deletions src/components/datagrid/data_grid.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,7 @@ describe('EuiDataGrid', () => {
);

expect(gridRef.current).toEqual({
setIsFullScreen: expect.any(Function),
setFocusedCell: expect.any(Function),
});
});
Expand Down
1 change: 1 addition & 0 deletions src/components/datagrid/data_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export const EuiDataGrid = forwardRef<EuiDataGridRefProps, EuiDataGridProps>(
useImperativeHandle(
ref,
() => ({
setIsFullScreen,
setFocusedCell: ({ rowIndex, colIndex }) => {
focusContext.setFocusedCell([colIndex, rowIndex]);
},
Expand Down
4 changes: 4 additions & 0 deletions src/components/datagrid/data_grid_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ export type EuiDataGridProps = OneOf<
>;

export interface EuiDataGridRefProps {
/**
* Allows manually controlling the full-screen state of the grid.
*/
setIsFullScreen(isFullScreen: boolean): void;
/**
* Allows manually focusing the specified cell in the grid.
*
Expand Down

0 comments on commit 429add8

Please sign in to comment.