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: ion-tab-bar is not working when used as a standalone Vue component after the v8.3.0/v8.3.1 update #29885

Closed
3 tasks done
ozgurg opened this issue Sep 20, 2024 · 5 comments · Fixed by #29940
Closed
3 tasks done
Labels
type: bug a confirmed bug report

Comments

@ozgurg
Copy link

ozgurg commented Sep 20, 2024

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

If the ion-tab-bar component is extracted as a standalone Vue component, it does not change the route and is basically broken after the v8.3.0/v8.3.1 update.

Expected Behavior

Works as expected, even when used as a standalone component, like before version v8.3.0/v8.3.1.

Steps to Reproduce

Folder Information:

Steps to Reproduce

  1. Run npm run dev in each folder individually.
  2. Open http://localhost:5173/.
  3. Switch between tabs.
  4. In folders 8.2.9, 8.2.9-standalone, and 8.3.0, you'll see the tabs and the route change correctly. However, in 8.3.0-standalone, the tab visually changes, but the route does not.

Code Reproduction URL

https://github.com/ozgurg/ionic-8.3.0-ion-tab-bar-vue-component-reproduce

Ionic Info

[WARN] Error loading @capacitor/ios package.json: Error: Cannot find module '@capacitor/ios/package.json'
       
       Require stack:
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/lib/project/index.js
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/lib/index.js
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/index.js
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/bin/ionic
[WARN] Error loading @capacitor/android package.json: Error: Cannot find module '@capacitor/android/package.json'
       
       Require stack:
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/lib/project/index.js
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/lib/index.js
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/index.js
       - /Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli/bin/ionic

Ionic:

   Ionic CLI       : 7.2.0 (/Users/ozgurg/.nvm/versions/node/v18.20.2/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/vue 8.3.0

Capacitor:

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

Utility:

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

System:

   NodeJS : v18.20.2 (/Users/ozgurg/.nvm/versions/node/v18.20.2/bin/node)
   npm    : 10.8.0
   OS     : macOS Unknown

Additional Information

The reproduce projects was created using ionic start myApp tabs. Only the versions of @ionic/vue and @ionic/vue-router were fixed to reproduce the bug. The only file modified was src/views/TabsPage.vue, and the only newly created file was src/components/TabBar.vue. Everything else remains the same as in the "tabs" starter template.

@ionitron-bot ionitron-bot bot added the triage label Sep 20, 2024
@manhtruongwang
Copy link

manhtruongwang commented Sep 26, 2024

Update, Ionic React Tabs break after 8.3.0 if set as a seperate components as well.

@DidoMarchet
Copy link

Hi, same issue with Vue.

Regards,
Davide

@brandyscarney brandyscarney added type: bug a confirmed bug report and removed triage labels Oct 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 16, 2024
Issue number: resolves #29885, resolves #29924

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

React and Vue:

Tab bar could be a standalone element within `IonTabs` and would
navigate without issues with a router outlet before v8.3:

```tsx
<IonTabs>
  <IonRouterOutlet></IonRouterOutlet>

  <IonTabBar></IonTabBar>
</IonTabs>
```

It would work as if it was written as:

```tsx
<IonTabs>
  <IonRouterOutlet></IonRouterOutlet>

  <IonTabBar slot="bottom">
    <!-- Buttons -->
  </IonTabBar>
</IonTabs>
```

After v8.3, any `ion-tab-bar` that was not a direct child of `ion-tabs`
would lose it's expected behavior when used with a router outlet. If a
user clicked on a tab button, then the content would not be redirected
to that expected view.

React only:

Users can no longer add a `ref` to the `IonRouterOutlet`, it always
returns undefined.

```
<IonTabs>
      <IonRouterOutlet ref={ref}>

     <IonTabBar slot="bottom">
    <!-- Buttons -->
  </IonTabBar>
</IonTabs>
```

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

The fixes were already reviewed through PR
#29925 and PR
#29927. I split them
to make it easier to review.

React and Vue:

The React tabs has been updated to pass data to the tab bar through
context instead of passing it through a ref. By using a context, the
data will be available for the tab bar to use regardless of its level.

React only:

Reverted the logic for `routerOutletRef` and added a comment of the
importance of it.

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

N/A
@manhtruongwang
Copy link

@thetaPC sorry for the ping, Vue is working right now but React still refuse to work with 8.3.3.

@thetaPC
Copy link
Contributor

thetaPC commented Oct 29, 2024

@manhtruongwang Please create a new issue and include a minimal repro so we can look into it. Thanks!

Copy link

ionitron-bot bot commented Nov 28, 2024

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug a confirmed bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants