Skip to content

bug: vue re-mounts intermediary views when not needed #23914

Closed

Description

@kabzko

Prequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

I have IonMenu with a list of routes.

When I push a page(Orders) for the first time all is well.
First
and again when I push to a new page for the second time it renders the new page(Products) and the old page(Orders).
Second
It affects my methods that I created for both pages. It calls all the created methods from both page.
Capture

Here's some video that I recorded
https://user-images.githubusercontent.com/41864097/132933264-769c352c-49ba-4174-9d0c-44719469d752.mp4

Expected Behavior

Old page must not be rendered again when you push to a new page

Steps to Reproduce

Just navigate from menu and check the console which I console log only text for testing.

Code Reproduction URL

https://github.com/kabzko/testroute

Ionic Info

Ionic:

Ionic CLI : 6.17.1

Utility:

cordova-res : 0.15.3
native-run : not installed globally

System:

NodeJS : v14.17.0
npm : 6.14.13
OS : Windows 10

Additional Information

No response

Activity

  1. whitersun commented on Sep 12, 2021

    @whitersun

    For more detail issue, please watch it.
    https://drive.google.com/file/d/1gNdeJHYdGitj_ApHNeUKQFXiwG8hJTRe/view?usp=sharing

    Description:
    When in home page router to Products, the Products page will render two components included the Order view page.
    But if we reload in child component like the Product page, then return home page. And router again to order then return the home router to products will no render also to components anymore.

    image

  2. UrosPavlovic commented on Sep 12, 2021

    @UrosPavlovic

    Same as for me. Currently in my new app, i have only 3 pages, home, login and register. Switching from Login to Register, vice versa, or from Home to either of them renders 2 views at same time. I can also post a video if needed.

    Relevant deps:
    "@ionic/vue": "^5.4.0",
    "@ionic/vue-router": "^5.4.0",
    "vue": "^3.2.1",
    "vue-router": "^4.0.0-0",

  3. changed the title [-]bug: IonRouterOutlet rerender old route when pushing new route[/-] [+]bug: vue re-mounts intermediary views when not needed[/+] on Sep 21, 2021
  4. added
    package: vue
    type: bug
    on Sep 21, 2021
  5. liamdebeasi commented on Sep 21, 2021

    @liamdebeasi
    Contributor

    Thanks for the issue. Looks like this line is the culprit: https://github.com/ionic-team/ionic-framework/blob/main/packages/vue/src/components/IonRouterOutlet.ts#L292 We probably need to be more specific about which views we remount by taking into account the delta value that the app was navigated with. I will look into a fix. As a temporary workaround, you can downgrade to v5.6.13.

  6. whitersun commented on Sep 28, 2021

    @whitersun

    Hi @liamdebeasi, I am afraid of if I downgrade to version 5.6.13 will influence the router.replace that got transition not remove from the prev view page rendered like the last issue of:
    https://forum.ionicframework.com/t/page-transition-with-router-replace/214614/8

    this was fixed that just not showing errors anymore. But that still had a router.replace problem, transition gets an incorrect view.
    #22654

  7. whitersun commented on Oct 4, 2021

    @whitersun

    Thanks for @liamdebeasi to point the problem, I finally solved this bug by changing abit code from

    const mountIntermediaryViews = (outletId: number, enteringViewItem: ViewItem, leavingViewItem: ViewItem) => {

    and below this link is my video record solution.
    https://drive.google.com/file/d/1QCvTexQ5ZqYlSwzaE4aHbfXc6TDzuJAA/view?usp=sharing

    Bug code:

      const mountIntermediaryViews = (outletId: number, enteringViewItem: ViewItem, leavingViewItem: ViewItem) => {
        const viewStack = viewStacks[outletId];
        if (!viewStack) return;
    
        const { enteringIndex: endIndex, leavingIndex: startIndex } = findViewIndex(viewStack, enteringViewItem, leavingViewItem);
    
        for (let i = startIndex + 1; i < endIndex; i++) {
          viewStack[i].mount = true;
        }
      }
    

    fixed code:

      const mountIntermediaryViews = (outletId: number, enteringViewItem: ViewItem, leavingViewItem: ViewItem) => {
        const viewStack = viewStacks[outletId];
        if (!viewStack) return;
    
        const { enteringIndex: endIndex, leavingIndex: startIndex } = findViewIndex(viewStack, enteringViewItem, leavingViewItem);
    
        for (let i = startIndex; i < endIndex; i++) {
          return viewStack[i].mount = true;
        }
      }
    

    or

      const mountIntermediaryViews = (outletId: number, enteringViewItem: ViewItem, leavingViewItem: ViewItem) => {
        const viewStack = viewStacks[outletId];
        if (!viewStack) return;
    
        const { enteringIndex: endIndex, leavingIndex: startIndex } = findViewIndex(viewStack, enteringViewItem, leavingViewItem);
    
        for (let i = startIndex + 1; i < endIndex; i++) {
          return viewStack[i - 1].mount = true;
        }
      }
    
  8. modified the milestones: 5.8.3, 5.8.4 on Oct 7, 2021
  9. 6 remaining items

  10. tigohenryschultz commented on Oct 11, 2021

    @tigohenryschultz
    Contributor

    Cleaning out my node modules and re-building to have a cleaner test

  11. tigohenryschultz commented on Oct 11, 2021

    @tigohenryschultz
    Contributor

    Can you reproduce the issue in an Ionic starter app? I cannot see this on my end, so it is hard to pinpoint what the issue may be.

    Nuked my node modules and rebuilt, it is fine and I don't see the bug anymore, thanks @liamdebeasi sorry for false flag

  12. liamdebeasi commented on Oct 11, 2021

    @liamdebeasi
    Contributor

    Glad the issue is resolved, and thanks for testing!

  13. liamdebeasi commented on Oct 14, 2021

    @liamdebeasi
    Contributor

    Thanks for the issue. This has been resolved via #24056, and a fix will be available in an upcoming release of Ionic Framework.

    Please feel free to continue testing the dev build, and let me know if you run into any issues. Thanks!

  14. added a commit that references this issue on Oct 14, 2021
    24659a5
  15. tigohenryschultz commented on Oct 22, 2021

    @tigohenryschultz
    Contributor

    We had to revert 5.9.0-dev.202110121546.9dce03f back to 5.8.3 because the @ionChange event stopped working on ion-radio-group

  16. liamdebeasi commented on Oct 22, 2021

    @liamdebeasi
    Contributor

    @tigohenryschultz Can you provide a reproduction?

  17. tigohenryschultz commented on Oct 22, 2021

    @tigohenryschultz
    Contributor

    Is there an ionic/vue boilerplate for jsfiddle.com I could point to the dev build for reproducing?

  18. liamdebeasi commented on Oct 22, 2021

    @liamdebeasi
    Contributor

    We do not have a boilerplate JSFiddle at the moment. The easiest approach is probably to create a blank Ionic starter app, reproduce the issue there, and then push that app to GitHub.

  19. tigohenryschultz commented on Oct 22, 2021

    @tigohenryschultz
    Contributor

    https://github.com/tigohenryschultz/radio-button-group-bug

    Select a radio option should trigger:

      console.log('radio changed to:', value);
    

    5.8.4 does, the 5.9.0 doesnt

  20. liamdebeasi commented on Oct 22, 2021

    @liamdebeasi
    Contributor

    Looks like that dev build had some other experimental work in it. Here's a new dev build with only the Vue fixes:

    npm install @ionic/[email protected] @ionic/[email protected]
    
  21. tigohenryschultz commented on Oct 22, 2021

    @tigohenryschultz
    Contributor

    Awesome, thanks again @liamdebeasi

  22. ionitron-bot commented on Nov 22, 2021

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  23. locked and limited conversation to collaborators on Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    package: vuetype: bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions