Skip to content

Commit

Permalink
[Console] Fix actions menu scrolling issue (#200018)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabarasaba authored Nov 17, 2024
1 parent 902f6db commit 0ed8230
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,19 @@ export class MonacoEditorActionsProvider {
visibility: 'hidden',
});
} else {
// if a request is selected, the actions buttons are placed at lineNumberOffset - scrollOffset
const offset = this.editor.getTopForLineNumber(lineNumber) - this.editor.getScrollTop();
const lineTop = this.editor.getTopForLineNumber(lineNumber);
const scrollTop = this.editor.getScrollTop();
const offset = lineTop - scrollTop;

// Ensure offset is never less than or equal to zero, moving it down
// by 1 px if needed.
const adjustedOffset = offset <= 0 ? 1 : offset;

this.setEditorActionsCss({
visibility: 'visible',
// Move position down by 1 px so that the action buttons panel doesn't cover the top border of the selected block
top: offset + 1,
// Move position down by 1 px so that the action buttons panel doesn't
// cover the top border of the selected block.
top: adjustedOffset + 1,
});
}
}
Expand Down
42 changes: 42 additions & 0 deletions test/functional/apps/console/_console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,48 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

it('should show actions menu when the first line of the request is not in the viewport', async () => {
await PageObjects.console.clearEditorText();
await PageObjects.console.enterText(`PUT _ingest/pipeline/testme
{
"processors": [
{
"inference": {
"model_id": "azure_openai_embeddings",
"input_output": {
"input_field": "body_content",
"output_field": "body_content_vector"
},
"if": "ctx?.body_content!=null",
"ignore_failure": true,
"on_failure": [
{
"append": {
"field": "_source._ingest.inference_errors",
"allow_duplicates": false,
"value": [
{
"message": "...",
"pipeline": "ml-inference-search-edf-azureopenai-embeddings",
"timestamp": "{{{ _ingest.timestamp }}}"
}
]
}
}
]
}
}
]
}`);

// Reduce the height of the browser window so that the first line of the request is not in the viewport
await browser.setWindowSize(1300, 500);
expect(await PageObjects.console.isPlayButtonVisible()).to.be(true);

// Reset it back to the original height
await browser.setWindowSize(1300, 1100);
});

it('Shows OK when status code is 200 but body is empty', async () => {
await PageObjects.console.clearEditorText();

Expand Down
4 changes: 4 additions & 0 deletions test/functional/page_objects/console_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ export class ConsolePageObject extends FtrService {
await this.testSubjects.click('sendRequestButton');
}

public async isPlayButtonVisible() {
return await this.testSubjects.exists('sendRequestButton');
}

public async clickCopyOutput() {
await this.testSubjects.click('copyOutputButton');
}
Expand Down

0 comments on commit 0ed8230

Please sign in to comment.