Skip to content

Commit

Permalink
Scroll to bottom on section add
Browse files Browse the repository at this point in the history
  • Loading branch information
Heenawter committed Feb 4, 2025
1 parent 6c0c83a commit 7627af8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
4 changes: 4 additions & 0 deletions examples/grid_example/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export const GridExample = ({
collapsed: false,
},
]);
// scroll to bottom after row is added
new Promise((resolve) => setTimeout(resolve, 60)).then(() => {
window.scrollTo({ top: document.body.scrollHeight, behavior: 'smooth' });
});
}}
disabled={viewMode !== 'edit'}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export interface GridLayoutProps {
setDragHandles?: (refs: Array<HTMLElement | null>) => void
) => React.ReactNode;
onLayoutChange: (newLayout: GridLayoutData) => void;
onRowAdded?: (rowId: string, rowRef: HTMLDivElement | null) => void;

className?: string; // this makes it so that custom CSS can be passed via Emotion
}
Expand All @@ -45,7 +44,6 @@ export const GridLayout = ({

renderPanelContents,
onLayoutChange,
onRowAdded,

className,
}: GridLayoutProps) => {
Expand Down Expand Up @@ -106,13 +104,6 @@ export const GridLayout = ({
.subscribe(([layoutBefore, layoutAfter]) => {
if (!isLayoutEqual(layoutBefore, layoutAfter)) {
onLayoutChange(layoutAfter);
if (onRowAdded && layoutBefore.length < layoutAfter.length) {
console.log(gridLayoutStateManager.rowRefs.current.length);
onRowAdded(
`kbnGridLayoutRow--${layoutAfter.length}`,
gridLayoutStateManager.rowRefs.current[layoutAfter.length]
);
}
}
});

Expand Down
14 changes: 0 additions & 14 deletions src/platform/packages/private/kbn-grid-layout/grid/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,4 @@ export interface PanelInteractionEvent {
};
}

// TODO: Remove from Dashboard plugin as part of https://github.com/elastic/kibana/issues/190446
export enum PanelPlacementStrategy {
/** Place on the very top of the grid layout, add the height of this panel to all other panels. */
placeAtTop = 'placeAtTop',
/** Look for the smallest y and x value where the default panel will fit. */
findTopLeftMostOpenSpace = 'findTopLeftMostOpenSpace',
}

export interface PanelPlacementSettings {
strategy?: PanelPlacementStrategy;
height: number;
width: number;
}

export type GridAccessMode = 'VIEW' | 'EDIT';

0 comments on commit 7627af8

Please sign in to comment.