Skip to content

Commit 4cd9739

Browse files
committed
Fix microsoft#52274 - don't move focus when clicking the find option buttons with screenreader mode turned on, because NVDA sends click events instead of key events when pressing space on a focused button
1 parent 529f705 commit 4cd9739

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

src/vs/base/browser/ui/findinput/findInput.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export class FindInput extends Widget {
4646
private placeholder: string;
4747
private validation: IInputValidator;
4848
private label: string;
49+
private fixFocusOnOptionClickEnabled = true;
4950

5051
private inputActiveOptionBorder: Color;
5152
private inputBackground: Color;
@@ -146,6 +147,10 @@ export class FindInput extends Widget {
146147
this.caseSensitive.disable();
147148
}
148149

150+
public setFocusInputOnOptionClick(value: boolean): void {
151+
this.fixFocusOnOptionClickEnabled = value;
152+
}
153+
149154
public setEnabled(enabled: boolean): void {
150155
if (enabled) {
151156
this.enable();
@@ -312,7 +317,7 @@ export class FindInput extends Widget {
312317
}));
313318
this._register(this.regex.onChange(viaKeyboard => {
314319
this._onDidOptionChange.fire(viaKeyboard);
315-
if (!viaKeyboard) {
320+
if (!viaKeyboard && this.fixFocusOnOptionClickEnabled) {
316321
this.inputBox.focus();
317322
}
318323
this.setInputWidth();
@@ -329,7 +334,7 @@ export class FindInput extends Widget {
329334
}));
330335
this._register(this.wholeWords.onChange(viaKeyboard => {
331336
this._onDidOptionChange.fire(viaKeyboard);
332-
if (!viaKeyboard) {
337+
if (!viaKeyboard && this.fixFocusOnOptionClickEnabled) {
333338
this.inputBox.focus();
334339
}
335340
this.setInputWidth();
@@ -343,7 +348,7 @@ export class FindInput extends Widget {
343348
}));
344349
this._register(this.caseSensitive.onChange(viaKeyboard => {
345350
this._onDidOptionChange.fire(viaKeyboard);
346-
if (!viaKeyboard) {
351+
if (!viaKeyboard && this.fixFocusOnOptionClickEnabled) {
347352
this.inputBox.focus();
348353
}
349354
this.setInputWidth();

src/vs/editor/contrib/find/findWidget.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,12 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
159159
if (e.layoutInfo) {
160160
this._tryUpdateWidgetWidth();
161161
}
162+
163+
if (e.accessibilitySupport) {
164+
this.updateAccessibilitySupport();
165+
}
162166
}));
167+
this.updateAccessibilitySupport();
163168
this._register(this._codeEditor.onDidChangeCursorSelection(() => {
164169
if (this._isVisible) {
165170
this._updateToggleSelectionFindButton();
@@ -840,6 +845,8 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
840845

841846
findPart.appendChild(this._closeBtn.domNode);
842847

848+
this.updateAccessibilitySupport();
849+
843850
return findPart;
844851
}
845852

@@ -959,6 +966,11 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
959966
}
960967
}));
961968
}
969+
970+
private updateAccessibilitySupport(): void {
971+
const value = this._codeEditor.getConfiguration().accessibilitySupport;
972+
this._findInput.setFocusInputOnOptionClick(value !== platform.AccessibilitySupport.Enabled);
973+
}
962974
}
963975

964976
interface ISimpleCheckboxOpts {

src/vs/workbench/parts/search/browser/searchView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
323323

324324
this._register(this.searchWidget.onSearchSubmit(() => this.onQueryChanged()));
325325
this._register(this.searchWidget.onSearchCancel(() => this.cancelSearch()));
326-
this._register(this.searchWidget.searchInput.onDidOptionChange((viaKeyboard) => this.onQueryChanged(viaKeyboard)));
326+
this._register(this.searchWidget.searchInput.onDidOptionChange(() => this.onQueryChanged(true)));
327327

328328
this._register(this.searchWidget.onReplaceToggled(() => this.onReplaceToggled()));
329329
this._register(this.searchWidget.onReplaceStateChange((state) => {

src/vs/workbench/parts/search/browser/searchWidget.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ export class SearchWidget extends Widget {
136136
this.replaceInputBoxFocused = Constants.ReplaceInputBoxFocusedKey.bindTo(this.contextKeyService);
137137
this._replaceHistoryDelayer = new Delayer<void>(500);
138138
this.render(container, options);
139+
140+
this.configurationService.onDidChangeConfiguration(e => {
141+
if (e.affectsConfiguration('editor.accessibilitySupport')) {
142+
this.updateAccessibilitySupport();
143+
}
144+
});
145+
this.updateAccessibilitySupport();
139146
}
140147

141148
public focus(select: boolean = true, focusReplace: boolean = false, suppressGlobalSearchBuffer = false): void {
@@ -237,6 +244,11 @@ export class SearchWidget extends Widget {
237244
this.renderReplaceInput(this.domNode, options);
238245
}
239246

247+
private updateAccessibilitySupport(): void {
248+
const value = this.configurationService.getValue('editor.accessibilitySupport');
249+
this.searchInput.setFocusInputOnOptionClick(value !== 'on');
250+
}
251+
240252
private renderToggleReplaceButton(parent: HTMLElement): void {
241253
const opts: IButtonOptions = {
242254
buttonBackground: null,

0 commit comments

Comments
 (0)