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

bug: vue, updating class attribute causes tabs state to get changed #24615

Open
4 of 6 tasks
virusv opened this issue Jan 20, 2022 · 1 comment
Open
4 of 6 tasks

bug: vue, updating class attribute causes tabs state to get changed #24615

virusv opened this issue Jan 20, 2022 · 1 comment
Labels
package: vue @ionic/vue package type: bug a confirmed bug report

Comments

@virusv
Copy link

virusv commented Jan 20, 2022

Prerequisites

Ionic Framework Version

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

Current Behavior

If you use dynamic attributes on the ion-tabs and ion-tab-bar elements, such as class or style. When switching between tabs, their history is reset.

Expected Behavior

Changing the class and other attributes of ion-tabs and ion-tab-bar does not reset the tab history.

Steps to Reproduce

  1. Clone repository (code reproduction URL)
  2. npm install && npm run serve
  3. Follow the steps below ↓

[tab X] - click action on a tab named X
→ - go to the child page (click on the next button)

Tab behavior, with dynamic attributes in ion-tabs or ion-tab-bar (for example, it can be class or style)
Transition option 1: [tab A] A0 → A1 → A2 [tab B] B0 → B1 → B2 [tab C] C0 → C1 → C2 [tab A] A0 (ERROR) [tab B] B0 (ERROR) [tab C ] C0 (ERROR)
Transition option 2: [tab A] A0 → A1 → A2 [tab B] B0 → B1 [tab A] A0 (ERROR)
Jump option 3: [tab A] A0 → A1 → A2 [tab B] B0 [tab A] A2 [tab B] B0 [tab C] C0 [tab A] A0 (ERROR)

Error.history.mp4

Open file scr/views/TabsPage.vue, comment block:

onBeforeUnmount(router.beforeEach((to, from, next) => {
  className.value = 'class-name-' + Math.round(Math.random() * 10000);
  next();
}));

Normal tab behavior:
Transition option 1: [tab A] A0 → A1 → A2 [tab B] B0 → B1 → B2 [tab C] C0 → C1 → C2 [tab A] A2 [tab B] B2 [tab C] C2
Transition option 2: [tab A] A0 → A1 → A2 [tab B] B0 → B1 [tab A] A2
Transition option 3: [tab A] A0 → A1 → A2 [tab B] B0 [tab A] A2 [tab B] B0 [tab C] C0 [tab A] A2

Ok.history.mp4

Code Reproduction URL

https://github.com/virusv/ionic-tabs-app-router-bug

Ionic Info

Ionic:

Ionic CLI : 6.18.1 (C:\Users\naliv\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/vue 6.0.3

Capacitor:

Capacitor CLI : 3.4.0
@capacitor/android : not installed
@capacitor/core : 3.4.0
@capacitor/ios : not installed

Utility:

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

System:

NodeJS : v16.13.1 (C:\Program Files\nodejs\node.exe)
npm : 8.1.2
OS : Windows 10

Additional Information

This is all due to the updated() event firing on the Vue ion-tab-bar component, which in turn calls setupTabState(ionRouter: any) which resets the tab history.

@ionitron-bot ionitron-bot bot added the triage label Jan 20, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the issue. I can reproduce this. It looks like updating the class attribute is causing a re-render of the tabs components, causing these methods to re-run as if they were being setup for the first time: https://github.com/ionic-team/ionic-framework/blob/main/packages/vue/src/components/IonTabBar.ts#L50

@liamdebeasi liamdebeasi changed the title bug: (Vue) Using dynamic attributes in ion-tabs leads to state reset and application tabs not working properly bug: vue, updating class attribute causes tabs state to get changed Jan 21, 2022
@liamdebeasi liamdebeasi added package: vue @ionic/vue package type: bug a confirmed bug report labels Jan 21, 2022
@ionitron-bot ionitron-bot bot removed the triage label Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: vue @ionic/vue package type: bug a confirmed bug report
Projects
None yet
Development

No branches or pull requests

2 participants