diff --git a/.changeset/stale-dots-speak.md b/.changeset/stale-dots-speak.md new file mode 100644 index 000000000..ced2862e8 --- /dev/null +++ b/.changeset/stale-dots-speak.md @@ -0,0 +1,5 @@ +--- +'@alauda/ui': patch +--- + +- fix: no default config for using component mode diff --git a/src/drawer/drawer.service.ts b/src/drawer/drawer.service.ts index fada83d1e..175529798 100644 --- a/src/drawer/drawer.service.ts +++ b/src/drawer/drawer.service.ts @@ -46,10 +46,12 @@ export class DrawerService< } updateOptions(options: DrawerOptions): void { - this.options = { - ...(DEFAULT_OPTIONS as DrawerOptions), - ...options, - }; + this.options = merge( + { + ...DEFAULT_OPTIONS, + }, + options, + ); } private createOverlay() { @@ -135,3 +137,13 @@ export class DrawerService< this.dispose(); } } + +function merge(object: Record, source: Record) { + Object.keys(source).forEach(key => { + if (source[key] === undefined) { + return; + } + object[key] = source[key]; + }); + return object; +}