fix(theme): prevent glitch when algolia chunk is loaded (#2519)

pull/2523/head
Divyansh Singh 1 year ago committed by GitHub
parent 5013835f51
commit 51661def8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,6 +26,7 @@ const { theme, localeIndex } = useData()
// payload), we delay initializing it until the user has actually clicked or // payload), we delay initializing it until the user has actually clicked or
// hit the hotkey to invoke it. // hit the hotkey to invoke it.
const loaded = ref(false) const loaded = ref(false)
const actuallyLoaded = ref(false)
const buttonText = computed(() => { const buttonText = computed(() => {
const options = theme.value.search?.options ?? theme.value.algolia const options = theme.value.search?.options ?? theme.value.algolia
@ -169,9 +170,10 @@ const provider = __ALGOLIA__ ? 'algolia' : __VP_LOCAL_SEARCH__ ? 'local' : ''
<VPAlgoliaSearchBox <VPAlgoliaSearchBox
v-if="loaded" v-if="loaded"
:algolia="theme.search?.options ?? theme.algolia" :algolia="theme.search?.options ?? theme.algolia"
@vue:beforeMount="actuallyLoaded = true"
/> />
<div v-else id="docsearch"> <div v-if="!actuallyLoaded" id="docsearch">
<VPNavBarSearchButton :placeholder="buttonText" @click="load" /> <VPNavBarSearchButton :placeholder="buttonText" @click="load" />
</div> </div>
</template> </template>

Loading…
Cancel
Save