Skip to content

Commit

Permalink
fix: repeat drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongping committed Nov 30, 2021
1 parent 5fa4072 commit c2f96ac
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-badgers-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alauda/ui': patch
---

repeat drawer fix
7 changes: 3 additions & 4 deletions src/drawer/component/drawer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ export class DrawerService {
constructor(private readonly overlay: Overlay) {}

open<T = any>(options: DrawerOptions<T>) {
if (!this.drawerRef) {
this.createDrawer();
this.updateOptions(options);
}
this.drawerRef?.instance?.closure();
this.createDrawer();
this.updateOptions(options);
return this.drawerRef?.instance;
}

Expand Down
26 changes: 24 additions & 2 deletions stories/drawer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ storiesOf('Drawer', module)
.add('service create component drawer', () => ({
moduleMetadata: {
imports: [ButtonModule, DrawerModule],
declarations: [ServiceDrawerCptComponent, DrawerContentComponent],
entryComponents: [DrawerContentComponent],
declarations: [
ServiceDrawerCptComponent,
DrawerContentComponent,
DrawerContent1Component,
],
entryComponents: [DrawerContentComponent, DrawerContent1Component],
},
component: ServiceDrawerCptComponent,
}));
Expand Down Expand Up @@ -154,6 +158,7 @@ export class ServiceDrawerComponent {
@Component({
template: `
<button aui-button="primary" (click)="open()">打开component抽屉</button>
<button aui-button="primary" (click)="openTwo()">打开component2抽屉</button>
<button aui-button (click)="close()">关闭</button>
`,
})
Expand All @@ -177,6 +182,16 @@ export class ServiceDrawerCptComponent {
});
}

openTwo() {
this.drawerService.open({
title: 'title',
width: 500,
content: DrawerContent1Component,
contentParams: { data: 222 },
footer: 'footer',
});
}

close() {
this.drawerRef.closure('on close');
}
Expand All @@ -188,3 +203,10 @@ export class ServiceDrawerCptComponent {
export class DrawerContentComponent {
@Input() data: string;
}

@Component({
template: `component {{ data }}`,
})
export class DrawerContent1Component {
@Input() data: string;
}

0 comments on commit c2f96ac

Please sign in to comment.