fix(theme): use a getter as VPSidebar's open watch source

`watch([props, navEl], ...)` is only accidentally valid on the client,
where props reaching setup are shallow-reactive. During SSR props are
not reactified (dev mode additionally wraps them in shallowReadonly),
so dev-flavored SSR warns "Invalid watch source: Proxy({ open: false })"
once per rendered page. Normally invisible because build() forces
NODE_ENV=production before vue loads — but any process that already
required vue under a different NODE_ENV (programmatic builds inside
test runners) keeps dev vue in the module cache and surfaces it.

Repro (pure Vue, no vitepress): renderToString of a component doing
watch([props, ref], cb, { immediate: true, flush: 'post' }) under dev
vue. Watching `() => props.open` expresses the actual dependency and
is valid in both environments.
pull/5307/merge
Divyansh Singh 3 weeks ago
parent 548a606447
commit 9aeeb4fa31

@ -15,7 +15,7 @@ const navEl = ref<HTMLElement | null>(null)
const isLocked = useBodyScrollLock() const isLocked = useBodyScrollLock()
watch( watch(
[props, navEl], [() => props.open, navEl],
() => { () => {
if (props.open) { if (props.open) {
isLocked.value = true isLocked.value = true

Loading…
Cancel
Save