Fixed tab indicator on wrong position when using back button

This commit is contained in:
squidfunk 2022-03-26 09:03:06 +01:00
parent 8358a9b162
commit 6976b9fd31
4 changed files with 17 additions and 11 deletions

View File

@ -214,7 +214,7 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.e87a5f81.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.5ea521e9.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %} {% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script> <script src="{{ path | url }}"></script>
{% endfor %} {% endfor %}

View File

@ -24,6 +24,7 @@ import {
Observable, Observable,
Subject, Subject,
animationFrameScheduler, animationFrameScheduler,
asyncScheduler,
auditTime, auditTime,
combineLatest, combineLatest,
defer, defer,
@ -33,6 +34,7 @@ import {
mapTo, mapTo,
merge, merge,
startWith, startWith,
subscribeOn,
takeLast, takeLast,
takeUntil, takeUntil,
tap tap
@ -73,7 +75,8 @@ export interface ContentTabs {
export function watchContentTabs( export function watchContentTabs(
el: HTMLElement el: HTMLElement
): Observable<ContentTabs> { ): Observable<ContentTabs> {
const inputs = getElements(":scope > input", el) const inputs = getElements<HTMLInputElement>(":scope > input", el)
const active = inputs.find(input => input.checked) || inputs[0]
return merge(...inputs.map(input => fromEvent(input, "change") return merge(...inputs.map(input => fromEvent(input, "change")
.pipe( .pipe(
mapTo<ContentTabs>({ mapTo<ContentTabs>({
@ -83,7 +86,7 @@ export function watchContentTabs(
)) ))
.pipe( .pipe(
startWith({ startWith({
active: getElement(`label[for=${inputs[0].id}]`) active: getElement(`label[for=${active.id}]`)
} as ContentTabs) } as ContentTabs)
) )
} }
@ -144,4 +147,7 @@ export function mountContentTabs(
map(state => ({ ref: el, ...state })) map(state => ({ ref: el, ...state }))
) )
}) })
.pipe(
subscribeOn(asyncScheduler)
)
} }