Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/10977.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Add auto scroll when new line is added ([#10977](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10977))
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ describe('useQueryPanelEditor', () => {
getOffsetAt: jest.fn(() => 10),
getValue: jest.fn(() => 'test query'),
getWordUntilPosition: jest.fn(() => ({ startColumn: 1, endColumn: 5 })),
getModel: jest.fn(() => ({ getLineCount: jest.fn() })),
revealLine: jest.fn(),
};

mockDataset = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ export const useQueryPanelEditor = (): UseQueryPanelEditorReturnType => {
vertical: contentHeight > maxHeight ? 'visible' : 'hidden',
},
});

// Automatically scroll to the bottom when new lines are added
if (contentHeight > finalHeight) {
const lastLine = editor.getModel()?.getLineCount() || 0;
editor.revealLine(lastLine);
}
});

return () => {
Expand Down
Loading