Skip to content

Commit

Permalink
Merge branch 'cmq/feat-#INFR-8645' of https://github.com/atinc/ngx-te…
Browse files Browse the repository at this point in the history
…thys into cmq/feat-#INFR-8645
  • Loading branch information
mengshuicmq committed Jul 13, 2023
2 parents 0ffbab8 + adc34ee commit 0006186
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/color-picker/color-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ export class ThyColorPickerDirective extends ThyOverlayDirectiveBase implements
/**
* panel 展开后触发
*/
@Output() thyPanelOpen: EventEmitter<void> = new EventEmitter<void>();
@Output() thyPanelOpen: EventEmitter<ThyPopoverRef<ThyColorPickerPanelComponent>> = new EventEmitter<
ThyPopoverRef<ThyColorPickerPanelComponent>
>();

/**
* panel 关闭后触发
*/
@Output() thyPanelClose: EventEmitter<void> = new EventEmitter<void>();
@Output() thyPanelClose: EventEmitter<ThyPopoverRef<ThyColorPickerPanelComponent>> = new EventEmitter<
ThyPopoverRef<ThyColorPickerPanelComponent>
>();

/**
* 弹出悬浮层的触发方式
Expand Down Expand Up @@ -180,10 +184,10 @@ export class ThyColorPickerDirective extends ThyOverlayDirectiveBase implements
});
if (this.popoverRef) {
this.popoverRef.afterOpened().subscribe(() => {
this.thyPanelOpen.emit();
this.thyPanelOpen.emit(this.popoverRef);
});
this.popoverRef.afterClosed().subscribe(() => {
this.thyPanelClose.emit();
this.thyPanelClose.emit(this.popoverRef);
});
}
if (this.popoverRef && !this.thyHasBackdrop) {
Expand Down
6 changes: 4 additions & 2 deletions src/color-picker/test/color-picker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import { ThyColorPickerModule } from '../module';
[thyShowDelay]="showDelay"
[thyHideDelay]="hideDelay"
(ngModelChange)="change($event)"
(thyPanelOpen)="panelOpen()"
(thyPanelClose)="panelClose()"
(thyPanelOpen)="panelOpen($event)"
(thyPanelClose)="panelClose($event)"
[thyPresetColors]="presetColors"></div>
<thy-color-picker-panel [colorChange]="defaultPanelColorChange" [color]="defaultPanelColor"></thy-color-picker-panel>
`,
Expand Down Expand Up @@ -355,6 +355,7 @@ describe(`color-picker`, () => {
openDefaultPanel();
fixture.detectChanges();
expect(panelOpen).toHaveBeenCalled();
expect(panelOpen).toHaveBeenCalledWith((colorPickerDirective as any).popoverRef);
}));

it('should dispatch thyPanelClose', fakeAsync(() => {
Expand All @@ -369,6 +370,7 @@ describe(`color-picker`, () => {
tick();
flush();
expect(panelClose).toHaveBeenCalled();
expect(panelClose).toHaveBeenCalledWith((colorPickerDirective as any).popoverRef);
}));

it('should get recentColors from localStorage', fakeAsync(() => {
Expand Down

0 comments on commit 0006186

Please sign in to comment.