From a9f0251619990b5794723ba1a29bc33660a07a88 Mon Sep 17 00:00:00 2001 From: Raymond Zhao <7199958+rzhao271@users.noreply.github.com> Date: Thu, 17 Nov 2022 14:29:22 -0800 Subject: [PATCH] Refactor "Modified in: User" indicator (#166645) Ref #159088 The "Modified in: User" indicator is not like other indicators, because it doesn't put up a hover, and it has a link in the label itself. This PR refactors that indicator and clarifies that tab focus goes straight to the link when using keyboard navigation. --- .../browser/settingsEditorSettingIndicators.ts | 8 ++++---- .../workbench/contrib/preferences/browser/settingsTree.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.ts b/src/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.ts index 761bfb044147e..4badb0a94e9f8 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsEditorSettingIndicators.ts @@ -5,7 +5,6 @@ import * as DOM from 'vs/base/browser/dom'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; -import { IMouseEvent } from 'vs/base/browser/mouseEvent'; import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget'; import { SimpleIconLabel } from 'vs/base/browser/ui/iconLabel/simpleIconLabel'; import { RunOnceScheduler } from 'vs/base/common/async'; @@ -236,7 +235,7 @@ export class SettingsTreeIndicatorsLabel implements IDisposable { } } - updateScopeOverrides(element: SettingsTreeSettingElement, elementDisposables: DisposableStore, onDidClickOverrideElement: Emitter, onApplyFilter: Emitter) { + updateScopeOverrides(element: SettingsTreeSettingElement, onDidClickOverrideElement: Emitter, onApplyFilter: Emitter) { this.scopeOverridesIndicator.element.innerText = ''; this.scopeOverridesIndicator.element.style.display = 'none'; if (element.hasPolicyValue) { @@ -286,6 +285,7 @@ export class SettingsTreeIndicatorsLabel implements IDisposable { // just to click into the one override there is. this.scopeOverridesIndicator.element.style.display = 'inline'; this.scopeOverridesIndicator.element.classList.remove('setting-indicator'); + this.scopeOverridesIndicator.element.removeAttribute('tabIndex'); this.scopeOverridesIndicator.disposables.clear(); const prefaceText = element.isConfigured ? @@ -295,8 +295,8 @@ export class SettingsTreeIndicatorsLabel implements IDisposable { const overriddenScope = element.overriddenScopeList[0]; const view = DOM.append(this.scopeOverridesIndicator.element, $('a.modified-scope', undefined, this.getInlineScopeDisplayText(overriddenScope))); - elementDisposables.add( - DOM.addStandardDisposableListener(view, DOM.EventType.CLICK, (e: IMouseEvent) => { + this.scopeOverridesIndicator.disposables.add( + DOM.addStandardDisposableListener(view, DOM.EventType.CLICK, (e) => { const [scope, language] = overriddenScope.split(':'); onDidClickOverrideElement.fire({ settingKey: element.setting.key, diff --git a/src/vs/workbench/contrib/preferences/browser/settingsTree.ts b/src/vs/workbench/contrib/preferences/browser/settingsTree.ts index 6f37adb815bef..31bd05ac769fd 100644 --- a/src/vs/workbench/contrib/preferences/browser/settingsTree.ts +++ b/src/vs/workbench/contrib/preferences/browser/settingsTree.ts @@ -885,7 +885,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre template.descriptionElement.innerText = element.description; } - template.indicatorsLabel.updateScopeOverrides(element, template.elementDisposables, this._onDidClickOverrideElement, this._onApplyFilter); + template.indicatorsLabel.updateScopeOverrides(element, this._onDidClickOverrideElement, this._onApplyFilter); const onChange = (value: any) => this._onDidChangeSetting.fire({ key: element.setting.key,