Fix #182308: Pressing PageUp in the search panel no longer causes the layout to change. (#213067)

Bug (previous behavior):
    1.Press Ctrl+Shift+F to open the search panel.
    2.Enter any text into the search input.
    3.Press PageUp/PageDown.
    4.The layout shifts to the right, hiding the line that indicates the current tab in the activity bar.

Solution:
When search results are displayed, pressing PageUp or PageDown now moves the cursor to the start or end of the search input, respectively. This is achieved by assigning specific functionality to these keys, overriding their default behavior of moving through the page.

Testing:
A smoke test was implemented to assess the fix. The test involves entering text into the search editor, pressing the PageUp and PageDown keys, and checking for any changes in the activity bar's layout.
This commit is contained in:
Francisca Carneiro 2024-06-04 23:13:40 +01:00 committed by GitHub
parent 4af0c6a8f4
commit f93c5bc0c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 45 additions and 0 deletions

View File

@ -665,6 +665,25 @@ export class SearchWidget extends Widget {
else if (keyboardEvent.equals(KeyCode.DownArrow)) {
stopPropagationForMultiLineDownwards(keyboardEvent, this.searchInput?.getValue() ?? '', this.searchInput?.domNode.querySelector('textarea') ?? null);
}
else if (keyboardEvent.equals(KeyCode.PageUp)) {
const inputElement = this.searchInput?.inputBox.inputElement;
if (inputElement) {
inputElement.setSelectionRange(0, 0);
inputElement.focus();
keyboardEvent.preventDefault();
}
}
else if (keyboardEvent.equals(KeyCode.PageDown)) {
const inputElement = this.searchInput?.inputBox.inputElement;
if (inputElement) {
const endOfText = inputElement.value.length;
inputElement.setSelectionRange(endOfText, endOfText);
inputElement.focus();
keyboardEvent.preventDefault();
}
}
}
private onCaseSensitiveKeyDown(keyboardEvent: IKeyboardEvent) {

View File

@ -61,6 +61,21 @@ export class Search extends Viewlet {
await this.submitSearch();
}
async hasActivityBarMoved() {
await this.code.waitForElement('.activitybar');
const elementBoundingBox = await this.code.driver.getElementXY('.activitybar');
return elementBoundingBox !== null && elementBoundingBox.x === 48 && elementBoundingBox.y === 375;
}
async waitForPageUp(): Promise<void> {
await this.code.dispatchKeybinding('PageUp');
}
async waitForPageDown(): Promise<void> {
await this.code.dispatchKeybinding('PageDown');
}
async submitSearch(): Promise<void> {
await this.waitForInputFocus(INPUT);

View File

@ -19,6 +19,17 @@ export function setup(logger: Logger) {
retry(async () => cp.execSync('git reset --hard HEAD --quiet', { cwd: app.workspacePathOrFolder }), 0, 5);
});
it('verifies the sidebar moves to the right', async function () {
const app = this.app as Application;
await app.workbench.search.openSearchViewlet();
await app.code.dispatchKeybinding('PageUp');
await app.workbench.search.hasActivityBarMoved();
await app.code.dispatchKeybinding('PageUp');
await app.workbench.search.hasActivityBarMoved();
});
it('searches for body & checks for correct result number', async function () {
const app = this.app as Application;
await app.workbench.search.openSearchViewlet();