Skip to content

Align current Drupal page with Nuxt page commits - #538

Open
StirStudios wants to merge 2 commits into
drunomics:2.xfrom
StirStudios:fix/current-page-commit-timing
Open

Align current Drupal page with Nuxt page commits#538
StirStudios wants to merge 2 commits into
drunomics:2.xfrom
StirStudios:fix/current-page-commit-timing

Conversation

@StirStudios

Copy link
Copy Markdown
Contributor

Summary

  • keep the fetched destination page key pending during client navigation
  • promote it to the page exposed by getPage() only when Nuxt emits page:finish
  • clear pending state after failed navigation or app:error
  • preserve immediate server assignment, hydration, redirects, custom keys, and fetchPage() results

Root cause

Nuxt keeps the outgoing <NuxtPage> committed while the destination resolves in Suspense. Drupal CE currently changes drupal-ce-current-page-key as soon as the destination request completes, or when its route watcher sees destination payload data. Shared layout components can consequently receive destination Drupal data while Nuxt is still displaying the outgoing page.

The required invariant is: getPage() represents the Drupal page Nuxt has committed, not the most recently completed request.

Change

The browser now tracks pending and current page keys separately. A completed destination fetch remains pending until page:finish, when Nuxt has committed it. Failed navigation and application errors discard the pending key. Server rendering still assigns immediately, hydration can expose its existing committed payload immediately, and redirect responses never become current pages.

This does not alter requests, cache keys, payload contents, redirect targets, CMS output, explicit custom-key lookups, or the page returned directly by fetchPage().

Evidence

  • full module suite: 35 files, 159 tests passed
  • focused regression coverage verifies:
    • destination fetch completion does not replace the current page early
    • page:finish promotes the destination
    • app:error discards pending state
  • focused ESLint check passed
  • DancePlug A/B reproduction:
    • existing behavior changed the current Drupal key 649 ms before page:finish
    • proposed behavior changes it with page:finish

This is intentionally separate from the consumer theme's route-snapshot lock: that protects route-derived shared UI, while this change corrects the lifecycle contract of Drupal CE's getPage() state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant