fire selection event when re-entered (#14857)

This commit is contained in:
Alan Ren
2021-03-24 16:40:20 -07:00
committed by GitHub
parent f59e9b5695
commit 2b7535f377

View File

@@ -42,6 +42,13 @@ export default class DeclarativeTableComponent extends ContainerBase<any, azdata
private _colorTheme: IColorTheme;
private _hasFocus: boolean;
/**
* The flag is set to true when the table gains focus. When a row is selected and the flag is true the row selected event will
* fire regardless whether the row is already selected.
*
*/
private _rowSelectionFocusFlag: boolean = false;
constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
@@ -309,8 +316,9 @@ export default class DeclarativeTableComponent extends ContainerBase<any, azdata
if (!this.enableRowSelection) {
return;
}
if (!this.isRowSelected(row)) {
if (this._rowSelectionFocusFlag || !this.isRowSelected(row)) {
this._selectedRow = row;
this._rowSelectionFocusFlag = false;
this._changeRef.detectChanges();
this.fireEvent({
@@ -370,6 +378,7 @@ export default class DeclarativeTableComponent extends ContainerBase<any, azdata
onFocusIn() {
this._hasFocus = true;
this._rowSelectionFocusFlag = true;
this._changeRef.detectChanges();
}