mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 09:35:36 -05:00
Fix modal event propagation (#8050)
* Fix event propagation * Remove unneeded onkeyup method * Move event handling code into SQL classes
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
Output, OnChanges, SimpleChanges, EventEmitter
|
||||
} from '@angular/core';
|
||||
|
||||
import { Checkbox as vsCheckbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
||||
import { Checkbox as sqlCheckbox } from 'sql/base/browser/ui/checkbox/checkbox';
|
||||
|
||||
@Component({
|
||||
selector: 'checkbox',
|
||||
@@ -22,14 +22,14 @@ export class Checkbox implements OnInit, OnChanges {
|
||||
|
||||
@Output() onChange = new EventEmitter<boolean>();
|
||||
|
||||
private _checkbox: vsCheckbox;
|
||||
private _checkbox: sqlCheckbox;
|
||||
|
||||
constructor(
|
||||
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this._checkbox = new vsCheckbox(this._el.nativeElement, {
|
||||
this._checkbox = new sqlCheckbox(this._el.nativeElement, {
|
||||
label: this.label,
|
||||
ariaLabel: this.ariaLabel || this.label,
|
||||
checked: this.checked,
|
||||
|
||||
@@ -13,6 +13,9 @@ import { IMessage, MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import * as nls from 'vs/nls';
|
||||
import { renderFormattedText, renderText, FormattedTextRenderOptions } from 'vs/base/browser/formattedTextRenderer';
|
||||
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { SelectBoxList } from 'vs/base/browser/ui/selectBox/selectBoxCustom';
|
||||
|
||||
const $ = dom.$;
|
||||
|
||||
@@ -91,6 +94,23 @@ export class SelectBox extends vsSelectBox {
|
||||
this._register(focusTracker);
|
||||
this._register(focusTracker.onDidBlur(() => this._hideMessage()));
|
||||
this._register(focusTracker.onDidFocus(() => this._showMessage()));
|
||||
// Stop propagation - we've handled the event already and letting it bubble up causes issues with parent
|
||||
// controls handling it (such as dialog pages)
|
||||
this.onkeydown(this.selectElement, (e: IKeyboardEvent) => {
|
||||
if (e.keyCode === KeyCode.Enter) {
|
||||
dom.EventHelper.stop(e, true);
|
||||
}
|
||||
});
|
||||
if (this.selectBoxDelegate instanceof SelectBoxList) {
|
||||
// SelectBoxList uses its own custom drop down list so we need to also stop propagation from that or it'll
|
||||
// also bubble up
|
||||
this.onkeydown(this.selectBoxDelegate.selectDropDownContainer, (e: IKeyboardEvent) => {
|
||||
if (e.keyCode === KeyCode.Enter) {
|
||||
dom.EventHelper.stop(e, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user