Skip to content

Commit

Permalink
Refactor "Modified in: User" indicator
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rzhao271 committed Nov 17, 2022
1 parent f5fad79 commit d6c13e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -236,7 +235,7 @@ export class SettingsTreeIndicatorsLabel implements IDisposable {
}
}

updateScopeOverrides(element: SettingsTreeSettingElement, elementDisposables: DisposableStore, onDidClickOverrideElement: Emitter<ISettingOverrideClickEvent>, onApplyFilter: Emitter<string>) {
updateScopeOverrides(element: SettingsTreeSettingElement, onDidClickOverrideElement: Emitter<ISettingOverrideClickEvent>, onApplyFilter: Emitter<string>) {
this.scopeOverridesIndicator.element.innerText = '';
this.scopeOverridesIndicator.element.style.display = 'none';
if (element.hasPolicyValue) {
Expand Down Expand Up @@ -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 ?
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d6c13e3

Please sign in to comment.