Closed
Description
🐛 The bug
- Go to https://scripts-phi.vercel.app/third-parties/youtube/nuxt-scripts
- DO NOT click the video
- Click "Nuxt Scripts"
- Click "YouTube" in Third Party Components
- Try to play the video
- See that the script won't load the video
This also happens with other scripts like Vimeo, Google Maps, Intercom.
🛠️ To reproduce
https://scripts-phi.vercel.app/third-parties/youtube/nuxt-scripts
🌈 Expected behavior
The script should be loaded after triggered but for some reason, it doesn't.
ℹ️ Additional context
This may be a temporary solution but I propose to set the trigger option as 'manual'
and then load it with load()
when the trigger promise is resolved.
For example in ScriptYouTubePlayer.vue
//
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl })
const { onLoaded, status, load } = useScriptYouTubePlayer({
scriptOptions: {
trigger: 'manual', // <- Load the script manually
},
})
const player: Ref<YT.Player | undefined> = ref()
let clickTriggered = false
if (props.trigger === 'mousedown') {
trigger.then(() => {
load() // <- Call load when trigger resolves
clickTriggered = true
})
}
onMounted(() => {
onLoaded(async (instance) => {
// ...
}
})
//