Skip to content

Commit

Permalink
HParams: Close the context menu after a column is removed (#6472)
Browse files Browse the repository at this point in the history
## Motivation for features / changes
This is a bug fix. When removing a column via the context menu the
context menu should immediately close.

## Screenshots of UI changes (or N/A)
It closes now

![21dfb5be-cf29-4c10-ae55-0de19e284166](https://github.com/tensorflow/tensorboard/assets/78179109/b41061db-b972-46be-afaf-a5f4bcb13fec)
  • Loading branch information
rileyajones authored Jun 29, 2023
1 parent 8e206cd commit c9a398f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export class DataTableComponent implements OnDestroy, AfterContentInit {
return;
}
this.removeColumn.emit(this.contextMenuHeader);
this.contextMenu.close();
}

private getInsertIndex() {
Expand Down
15 changes: 6 additions & 9 deletions tensorboard/webapp/widgets/data_table/data_table_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ describe('data table', () => {
});
});

it('removes column when Remove button is clicked', fakeAsync(() => {
it('removes column when Remove button is clicked', () => {
const fixture = createComponent({
headers: mockHeaders,
data: mockTableData,
Expand All @@ -727,19 +727,16 @@ describe('data table', () => {
cell.nativeElement.dispatchEvent(new MouseEvent('contextmenu'));
fixture.detectChanges();

let columnRemoved: ColumnHeader | undefined = undefined;
fixture.componentInstance.removeColumn.subscribe((event) => {
columnRemoved = event;
});

spyOn(fixture.componentInstance.removeColumn, 'emit');
fixture.debugElement
.queryAll(By.css('.context-menu button'))
.find((btn) => btn.nativeElement.innerHTML.includes('Remove'))!
.nativeElement.click();
flush();
fixture.detectChanges();

expect(columnRemoved).toBeDefined();
}));
expect(fixture.componentInstance.removeColumn.emit).toHaveBeenCalled();
expect(fixture.debugElement.query(By.css('.context-menu'))).toBeNull();
});

it('does not include add buttons when there are no selectable columns', () => {
const fixture = createComponent({
Expand Down

0 comments on commit c9a398f

Please sign in to comment.