Skip to content

Commit

Permalink
Add missing keydown handlers to Settings editor (#167000)
Browse files Browse the repository at this point in the history
Add missing keydown event handlers

Ref #159088
  • Loading branch information
rzhao271 authored Nov 22, 2022
1 parent fb53973 commit 067d6cc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,25 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {

const overriddenScope = element.overriddenScopeList[0];
const view = DOM.append(this.scopeOverridesIndicator.element, $('a.modified-scope', undefined, this.getInlineScopeDisplayText(overriddenScope)));
this.scopeOverridesIndicator.disposables.add(
DOM.addStandardDisposableListener(view, DOM.EventType.CLICK, (e) => {
const [scope, language] = overriddenScope.split(':');
onDidClickOverrideElement.fire({
settingKey: element.setting.key,
scope: scope as ScopeString,
language
});
e.preventDefault();
e.stopPropagation();
}));
const onClickOrKeydown = (e: UIEvent) => {
const [scope, language] = overriddenScope.split(':');
onDidClickOverrideElement.fire({
settingKey: element.setting.key,
scope: scope as ScopeString,
language
});
e.preventDefault();
e.stopPropagation();
};
this.scopeOverridesIndicator.disposables.add(DOM.addDisposableListener(view, DOM.EventType.CLICK, (e) => {
onClickOrKeydown(e);
}));
this.scopeOverridesIndicator.disposables.add(DOM.addDisposableListener(view, DOM.EventType.KEY_DOWN, (e) => {
const ev = new StandardKeyboardEvent(e);
if (ev.equals(KeyCode.Space) || ev.equals(KeyCode.Enter)) {
onClickOrKeydown(e);
}
}));
} else {
this.scopeOverridesIndicator.element.style.display = 'inline';
this.scopeOverridesIndicator.element.classList.add('setting-indicator');
Expand Down
14 changes: 13 additions & 1 deletion src/vs/workbench/contrib/preferences/browser/settingsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import { ILanguageService } from 'vs/editor/common/languages/language';
import { ConfigurationScope } from 'vs/platform/configuration/common/configurationRegistry';
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
import { defaultButtonStyles, getInputBoxStyle } from 'vs/platform/theme/browser/defaultStyles';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';

const $ = DOM.$;

Expand Down Expand Up @@ -1078,12 +1079,23 @@ export class SettingComplexRenderer extends AbstractSettingRenderer implements I
? editLanguageSettingLabel
: SettingComplexRenderer.EDIT_IN_JSON_LABEL;

template.elementDisposables.add(DOM.addDisposableListener(template.button, DOM.EventType.CLICK, () => {
const onClickOrKeydown = (e: UIEvent) => {
if (isLanguageTagSetting) {
this._onApplyFilter.fire(`@${LANGUAGE_SETTING_TAG}${plainKey}`);
} else {
this._onDidOpenSettings.fire(dataElement.setting.key);
}
e.preventDefault();
e.stopPropagation();
};
template.elementDisposables.add(DOM.addDisposableListener(template.button, DOM.EventType.CLICK, (e) => {
onClickOrKeydown(e);
}));
template.elementDisposables.add(DOM.addDisposableListener(template.button, DOM.EventType.KEY_DOWN, (e) => {
const ev = new StandardKeyboardEvent(e);
if (ev.equals(KeyCode.Space) || ev.equals(KeyCode.Enter)) {
onClickOrKeydown(e);
}
}));

this.renderValidations(dataElement, template);
Expand Down

0 comments on commit 067d6cc

Please sign in to comment.