mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
fixes #103167
This commit is contained in:
parent
86c04f72be
commit
f74e473238
|
@ -749,6 +749,16 @@ export function getShadowRoot(domNode: Node): ShadowRoot | null {
|
|||
return isShadowRoot(domNode) ? domNode : null;
|
||||
}
|
||||
|
||||
export function getActiveElement(): Element | null {
|
||||
let result = document.activeElement;
|
||||
|
||||
while (result?.shadowRoot) {
|
||||
result = result.shadowRoot.activeElement;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function createStyleSheet(container: HTMLElement = document.getElementsByTagName('head')[0]): HTMLStyleElement {
|
||||
let style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
|
|
|
@ -173,7 +173,7 @@ export class ActionBar extends Disposable implements IActionRunner {
|
|||
|
||||
this.focusTracker = this._register(DOM.trackFocus(this.domNode));
|
||||
this._register(this.focusTracker.onDidBlur(() => {
|
||||
if (document.activeElement === this.domNode || !DOM.isAncestor(document.activeElement, this.domNode)) {
|
||||
if (DOM.getActiveElement() === this.domNode || !DOM.isAncestor(DOM.getActiveElement(), this.domNode)) {
|
||||
this._onDidBlur.fire();
|
||||
this.focusedItem = undefined;
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ export class ActionBar extends Disposable implements IActionRunner {
|
|||
private updateFocusedItem(): void {
|
||||
for (let i = 0; i < this.actionsList.children.length; i++) {
|
||||
const elem = this.actionsList.children[i];
|
||||
if (DOM.isAncestor(document.activeElement, elem)) {
|
||||
if (DOM.isAncestor(DOM.getActiveElement(), elem)) {
|
||||
this.focusedItem = i;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ export class ContextView extends Disposable {
|
|||
if (this.useShadowDOM) {
|
||||
this.shadowRootHostElement = DOM.$('.shadow-root-host');
|
||||
this.container.appendChild(this.shadowRootHostElement);
|
||||
this.shadowRoot = this.shadowRootHostElement.attachShadow({ mode: 'closed' });
|
||||
this.shadowRoot = this.shadowRootHostElement.attachShadow({ mode: 'open' });
|
||||
this.shadowRoot.innerHTML = `
|
||||
<style>
|
||||
${SHADOW_ROOT_CSS}
|
||||
|
|
|
@ -8,7 +8,7 @@ import * as strings from 'vs/base/common/strings';
|
|||
import { IActionRunner, IAction, SubmenuAction, Separator, IActionViewItemProvider } from 'vs/base/common/actions';
|
||||
import { ActionBar, ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses, clearNode, createStyleSheet, isInShadowDOM } from 'vs/base/browser/dom';
|
||||
import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses, clearNode, createStyleSheet, isInShadowDOM, isShadowRoot, getActiveElement } from 'vs/base/browser/dom';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||
|
@ -679,7 +679,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
|
|||
}, 250);
|
||||
|
||||
this.hideScheduler = new RunOnceScheduler(() => {
|
||||
if (this.element && (!isAncestor(document.activeElement, this.element) && this.parentData.submenu === this.mysubmenu)) {
|
||||
if (this.element && (!isAncestor(getActiveElement(), this.element) && this.parentData.submenu === this.mysubmenu)) {
|
||||
this.parentData.parent.focus(false);
|
||||
this.cleanupExistingSubmenu(true);
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
|
|||
this._register(addDisposableListener(this.element, EventType.KEY_DOWN, e => {
|
||||
let event = new StandardKeyboardEvent(e);
|
||||
|
||||
if (document.activeElement === this.item) {
|
||||
if (getActiveElement() === this.item) {
|
||||
if (event.equals(KeyCode.RightArrow) || event.equals(KeyCode.Enter)) {
|
||||
EventHelper.stop(e, true);
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
|
|||
}));
|
||||
|
||||
this._register(addDisposableListener(this.element, EventType.FOCUS_OUT, e => {
|
||||
if (this.element && !isAncestor(document.activeElement, this.element)) {
|
||||
if (this.element && !isAncestor(getActiveElement(), this.element)) {
|
||||
this.hideScheduler.schedule();
|
||||
}
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue