Skip to content

Commit

Permalink
[MNT-23166] Add resize flag to document list with option to disable blur
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas committed Nov 15, 2023
1 parent e5ca7d2 commit 7bba2d9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
[rowMenuCacheEnabled]="false"
[stickyHeader]="stickyHeader"
[allowFiltering]="allowFiltering"
[isResizingEnabled]="isResizingEnabled"
[blurOnResize]="blurOnResize"
(showRowContextMenu)="onShowRowContextMenu($event)"
(showRowActionsMenu)="onShowRowActionsMenu($event)"
(executeRowAction)="onExecuteRowAction($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
@Input()
maxColumnsVisible?: number;

/** Enables column resizing for datatable */
@Input()
isResizingEnabled = false;

/** Enables blur when resizing datatable columns */
@Input()
blurOnResize = true;

/** Emitted when the user clicks a list node */
@Output()
nodeClick = new EventEmitter<NodeEntityEvent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@

<div
class="adf-datatable-body"
[ngClass]="{ 'adf-blur-datatable-body': isDraggingHeaderColumn || isResizing }"
[ngClass]="{ 'adf-blur-datatable-body': blurOnResize && (isDraggingHeaderColumn || isResizing) }"
role="rowgroup">
<ng-container *ngIf="!loading && !noPermission">
<adf-datatable-row *ngFor="let row of data.getRows(); let idx = index"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1738,18 +1738,29 @@ describe('Column Resizing', () => {
expect(dragIcon).toBeNull();
});

it('should blur the table body upon resizing starts', () => {
dataTable.isResizingEnabled = true;
fixture.detectChanges();
describe('Datatable blur', () => {
beforeEach(() => {
dataTable.isResizingEnabled = true;
fixture.detectChanges();

const resizeHandle: HTMLElement = fixture.debugElement.nativeElement.querySelector('.adf-datatable__resize-handle');
resizeHandle.dispatchEvent(new MouseEvent('mousedown'));
fixture.detectChanges();
const resizeHandle: HTMLElement = fixture.debugElement.nativeElement.querySelector('.adf-datatable__resize-handle');
resizeHandle.dispatchEvent(new MouseEvent('mousedown'));
fixture.detectChanges();
});

const tableBody = fixture.debugElement.nativeElement.querySelector('.adf-datatable-body');
it('should blur the table body upon resizing starts', () => {
const tableBody = fixture.debugElement.nativeElement.querySelector('.adf-datatable-body');
expect(dataTable.isResizing).toBeTrue();
expect(tableBody.classList).toContain('adf-blur-datatable-body');
});

expect(dataTable.isResizing).toBeTrue();
expect(tableBody.classList).toContain('adf-blur-datatable-body');
it('should not blur the table body upon resizing starts when blurOnResize is false', () => {
dataTable.blurOnResize = false;
fixture.detectChanges();
const tableBody = fixture.debugElement.nativeElement.querySelector('.adf-datatable-body');
expect(dataTable.isResizing).toBeTrue();
expect(tableBody.classList).not.toContain('adf-blur-datatable-body');
});
});

it('should set column width on resizing', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ export class DataTableComponent implements OnInit, AfterContentInit, OnChanges,
@Input()
isResizingEnabled: boolean = false;

/**
* Flag that indicates if the datatable should be blurred when resizing.
*/
@Input()
blurOnResize: boolean = true;

headerFilterTemplate: TemplateRef<any>;
noContentTemplate: TemplateRef<any>;
noPermissionTemplate: TemplateRef<any>;
Expand Down

0 comments on commit 7bba2d9

Please sign in to comment.