Fixed details not opening on navigation (7.0.0 regression)

This commit is contained in:
squidfunk
2021-09-19 15:08:27 +02:00
parent 4a2af4ceaf
commit 726888cb56
5 changed files with 25 additions and 16 deletions

View File

@@ -39,7 +39,9 @@ import { Component } from "../../_"
/**
* Details
*/
export interface Details {}
export interface Details {
scroll?: boolean /* Scroll into view */
}
/* ----------------------------------------------------------------------------
* Helper types
@@ -80,8 +82,8 @@ export function watchDetails(
.pipe(
map(target => target.closest("details:not([open])")!),
filter(details => el === details),
mergeWith(print$),
mapTo(el)
mapTo({ scroll: true }),
mergeWith(print$.pipe(mapTo({})))
)
}
@@ -100,9 +102,10 @@ export function mountDetails(
el: HTMLDetailsElement, options: MountOptions
): Observable<Component<Details>> {
const internal$ = new Subject<Details>()
internal$.subscribe(() => {
internal$.subscribe(({ scroll }) => {
el.setAttribute("open", "")
el.scrollIntoView()
if (scroll)
el.scrollIntoView()
})
/* Create and return component */