make button not focusable when disabled (#16185)

* make button not focusable when disabled

* update comment

* add carbon edit tag
This commit is contained in:
Alan Ren
2021-07-15 15:10:54 -07:00
committed by GitHub
parent b3d8e522f7
commit 49dbce5171

View File

@@ -12,7 +12,7 @@ import { Event as BaseEvent, Emitter } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Gesture, EventType as TouchEventType } from 'vs/base/browser/touch'; import { Gesture, EventType as TouchEventType } from 'vs/base/browser/touch';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels'; import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { addDisposableListener, IFocusTracker, EventType, EventHelper, trackFocus, reset } from 'vs/base/browser/dom'; import { addDisposableListener, IFocusTracker, EventType, EventHelper, trackFocus, reset, removeTabIndexAndUpdateFocus } from 'vs/base/browser/dom'; // {{SQL CARBON EDIT}}
import { IContextMenuProvider } from 'vs/base/browser/contextmenu'; import { IContextMenuProvider } from 'vs/base/browser/contextmenu';
import { Action, IAction, IActionRunner } from 'vs/base/common/actions'; import { Action, IAction, IActionRunner } from 'vs/base/common/actions';
import { CSSIcon, Codicon } from 'vs/base/common/codicons'; import { CSSIcon, Codicon } from 'vs/base/common/codicons';
@@ -294,6 +294,7 @@ export class Button extends Disposable implements IButton {
} else { } else {
this._element.classList.add('disabled'); this._element.classList.add('disabled');
this._element.setAttribute('aria-disabled', String(true)); this._element.setAttribute('aria-disabled', String(true));
removeTabIndexAndUpdateFocus(this._element); // {{SQL CARBON EDIT}} - remove tabindex when disabled otherwise disabled control is still keyboard focusable.
} }
this.applyStyles(); // {{SQL CARBON EDIT}} this.applyStyles(); // {{SQL CARBON EDIT}}
} }