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>
{% endblock %}
{% 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"] %}
<script src="{{ path | url }}"></script>
{% endfor %}

View File

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