Wait for the search view's ref before watching it
Alpine registers x-ref as it walks the children, so $refs.view is not there yet when the component's init() runs. Plan step 13, finding IN-01. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qwx5USif3wFFmxtHg5U1g9
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
0ffb2b06db
commit
a13f5e44a6
@@ -43,8 +43,11 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.compact = query.matches
|
this.compact = query.matches
|
||||||
query.addEventListener('change', (event) => (this.compact = event.matches))
|
query.addEventListener('change', (event) => (this.compact = event.matches))
|
||||||
|
|
||||||
this.observer = new MutationObserver(() => this.countLater())
|
// Alpine registers x-ref as it walks the children, which is after this runs.
|
||||||
this.observer.observe(this.$refs.view, { childList: true, subtree: true, characterData: true })
|
this.$nextTick(() => {
|
||||||
|
this.observer = new MutationObserver(() => this.countLater())
|
||||||
|
this.observer.observe(this.$refs.view, { childList: true, subtree: true, characterData: true })
|
||||||
|
})
|
||||||
|
|
||||||
this.$watch('open', () => this.countLater())
|
this.$watch('open', () => this.countLater())
|
||||||
},
|
},
|
||||||
@@ -60,7 +63,7 @@ document.addEventListener('alpine:init', () => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
count() {
|
count() {
|
||||||
if (! this.open) {
|
if (! this.open || ! this.$refs.view) {
|
||||||
this.announcement = ''
|
this.announcement = ''
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user