From 3a3aefa64e0b1550f7f62c224e2d643c0f8ccb26 Mon Sep 17 00:00:00 2001 From: JounQin Date: Tue, 8 Aug 2023 17:47:39 +0800 Subject: [PATCH] fix(back-top): should prefer custom target (#490) --- .changeset/rich-dots-divide.md | 5 +++++ src/back-top/back-top.component.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/rich-dots-divide.md diff --git a/.changeset/rich-dots-divide.md b/.changeset/rich-dots-divide.md new file mode 100644 index 000000000..4f59d9524 --- /dev/null +++ b/.changeset/rich-dots-divide.md @@ -0,0 +1,5 @@ +--- +"@alauda/ui": patch +--- + +fix(back-top): should prefer custom target diff --git a/src/back-top/back-top.component.ts b/src/back-top/back-top.component.ts index be37d0123..38c0f52a1 100644 --- a/src/back-top/back-top.component.ts +++ b/src/back-top/back-top.component.ts @@ -115,7 +115,7 @@ export class BackTopComponent { getTarget(target: TargetType): Element | Window { const scrollTarget = - (typeof target === 'string' && document.querySelector(target)) || + (typeof target === 'string' ? document.querySelector(target) : target) || this.cdkScrollable?.getElementRef().nativeElement || window; this._scrollTarget = scrollTarget;