Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] [Console] Fix actions menu scrolling issue (#200018) #200330

Merged
merged 1 commit into from
Nov 17, 2024
Merged
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
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 @@ -216,6 +216,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