mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed details not opening on navigation (7.0.0 regression)
This commit is contained in:
parent
4a2af4ceaf
commit
726888cb56
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -223,7 +223,7 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.77d4fa84.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.527e4d51.min.js' | url }}"></script>
|
||||
{% for path in config["extra_javascript"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
@ -20,8 +20,13 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { Observable, fromEvent, of } from "rxjs"
|
||||
import { filter, map, share, startWith, switchMap } from "rxjs/operators"
|
||||
import { Observable, fromEvent } from "rxjs"
|
||||
import {
|
||||
filter,
|
||||
map,
|
||||
shareReplay,
|
||||
startWith
|
||||
} from "rxjs/operators"
|
||||
|
||||
import { createElement, getElement } from "~/browser"
|
||||
|
||||
@ -68,7 +73,7 @@ export function watchLocationHash(): Observable<string> {
|
||||
map(getLocationHash),
|
||||
startWith(getLocationHash()),
|
||||
filter(hash => hash.length > 0),
|
||||
share()
|
||||
shareReplay(1)
|
||||
)
|
||||
}
|
||||
|
||||
@ -80,6 +85,7 @@ export function watchLocationHash(): Observable<string> {
|
||||
export function watchLocationTarget(): Observable<HTMLElement> {
|
||||
return watchLocationHash()
|
||||
.pipe(
|
||||
switchMap(id => of(getElement(`[id="${id}"]`)!))
|
||||
map(id => getElement(`[id="${id}"]`)!),
|
||||
filter(el => typeof el !== "undefined")
|
||||
)
|
||||
}
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user