Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vue-app): always finish transition.leave asynchronously #5891

Merged
merged 4 commits into from
Jun 14, 2019

Conversation

pimlie
Copy link

@pimlie pimlie commented Jun 7, 2019

Fix: #5703

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

When transition.css = false and no leave listener with a callback/done argument is provided, the leave transition callback is called synchronously.

This causes a problem when switching layouts in Nuxt. Eg given page A with layout A and page B with layout B the following roughly happens (thus with transition.css = false):

  1. when page A is loaded the component tree is: Layout A -> Nuxt -> NuxtChild -> Transition -> RouterView -> Page A
  2. next user clicks link to page B
  3. Client app loads page component B and determines it needs layout B
  4. layout B is preloaded (App.loadLayout)
  5. router.next() is called
  6. leave transition for Page A is called
  7. leave transition immediately finishes (synchronously)
  8. Page B is loaded within Layout A
  9. router.afterEach calls Client.fixPrepatch
  10. Client.showNextPage is called
  11. Layout B is loaded (App.setLayout)
  12. Page B is loaded

By calling the leave callback in step 6/7 asynchronous (as would happen when eg transition.css is not false), all subsequent steps are called before the leave callback is called which means that Layout B will already be loaded and Page B is never loaded in Layout A.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

@pimlie pimlie requested a review from a team June 7, 2019 13:46
@codecov-io
Copy link

codecov-io commented Jun 7, 2019

Codecov Report

Merging #5891 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #5891   +/-   ##
=======================================
  Coverage   95.68%   95.68%           
=======================================
  Files          82       82           
  Lines        2689     2689           
  Branches      690      690           
=======================================
  Hits         2573     2573           
  Misses         98       98           
  Partials       18       18
Flag Coverage Δ
#e2e 100% <ø> (ø) ⬆️
#fixtures 50.35% <ø> (ø) ⬆️
#unit 92.67% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3f1f3b...b23c367. Read the comment docs.

@pi0 pi0 changed the title fix: always finish transition.leave asynchronously fix(vue-app): always finish transition.leave asynchronously Jun 7, 2019
@pi0 pi0 requested a review from atinux June 9, 2019 10:17
@pimlie
Copy link
Author

pimlie commented Jun 10, 2019

@pi0 @atinux One consideration that we might take away from this issue is that Nuxt.js fully relies on the asynchronous nature of transition resolving to prevent page components to be loaded twice when switching layouts. Not sure if this was an explicitly known thing or not, it took me quite a while at least to discover that ;)

@atinux
Copy link
Member

atinux commented Jun 11, 2019

Good catch @pimlie, these transitions makes it harder to work with the layouts actually, as well as the scrollBehaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mounted twice when layout change
6 participants