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: react, custom elements build flicker when switching tabs #24107

Closed
4 of 6 tasks
milanharia opened this issue Oct 22, 2021 · 16 comments
Closed
4 of 6 tasks

bug: react, custom elements build flicker when switching tabs #24107

milanharia opened this issue Oct 22, 2021 · 16 comments
Labels
package: react @ionic/react package type: bug a confirmed bug report v6 issues specific to Framework v6

Comments

@milanharia
Copy link

milanharia commented Oct 22, 2021

Prerequisites

Ionic Framework Version

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

Current Behavior

When switching between tabs, for a split second a blank page loads and then the page mounts. Consequently, you can see a flashing effect as the content all appears from a blank page. This bug does not happen in beta 5.

Expected Behavior

I expect the tab switching to happen instantly as it does in previous versions. I do not expect a blank page to momentarily appear.

Steps to Reproduce

This issue occurs when you nest IonRouterOutlet's which is necessary when you want to only render the tab bar on certain pages (for example do not render on a login page).

Code Reproduction URL

https://github.com/milanharia/tab-flashing-effect

Ionic Info

Ionic:

Ionic CLI : 6.17.1 (/Users/milan/.nvm/versions/node/v14.17.6/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 6.0.0-rc.0

Capacitor:

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

Utility:

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

System:

NodeJS : v14.17.6 (/Users/milan/.nvm/versions/node/v14.17.6/bin/node)
npm : 7.24.2
OS : macOS Big Sur

Additional Information

Simulator.Screen.Recording.-.iPhone.12.-.2021-10-22.at.10.57.09.mp4
@ionitron-bot ionitron-bot bot added the triage label Oct 22, 2021
@liamdebeasi
Copy link
Contributor

Thanks for the issue. Did you make your repo public? I cannot access it.

@liamdebeasi liamdebeasi added the needs: reply the issue needs a response from the user label Oct 22, 2021
@ionitron-bot ionitron-bot bot removed the triage label Oct 22, 2021
@milanharia
Copy link
Author

Sorry, it should be public now.

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Oct 22, 2021
@liamdebeasi
Copy link
Contributor

Thanks, I can reproduce this behavior. I think this broke in c50d895.

@liamdebeasi liamdebeasi changed the title bug: Blank page flashes momentarily when switching between tabs bug: react, custom elements build flicker when switching tabs Oct 22, 2021
@liamdebeasi liamdebeasi added package: react @ionic/react package type: bug a confirmed bug report v6 issues specific to Framework v6 labels Oct 22, 2021
@ionitron-bot ionitron-bot bot removed the triage label Oct 22, 2021
@milanharia
Copy link
Author

milanharia commented Oct 22, 2021

I am not sure if this is related to the same bug or not but the dismiss function from the useIonLoading hook does not dismiss the loader anymore.

E.g:

[present, dismiss] = useIonLoading()
<IonButton onClick{() => dismiss()}>Dismiss</IonButton>

@liamdebeasi
Copy link
Contributor

Yep, good thing to note. That was fixed by 655631d and will be fixed in the next Ionic 6 RC.

@liamdebeasi liamdebeasi added this to the 6.0.0-rc.4 milestone Nov 23, 2021
@sean-perkins
Copy link
Contributor

@milanharia following up on your issue, this appears to be related to the usage of nested IonRouterOutlet.

When using nested IonRouterOutlet it is encouraged to use the ionPage property on the nested outlet, to help the router better transition the pages: #20597 (comment)

If you update your example repository App.tsx to:

...
const App: React.FC = () => (
  <IonApp>
    <IonReactRouter>
      <IonRouterOutlet>
      <IonTabs>
        <IonRouterOutlet ionPage>
        ...

You will no longer see the tab bar flicker when navigating between tabs.

@sean-perkins sean-perkins added the needs: reply the issue needs a response from the user label Nov 30, 2021
@milanharia
Copy link
Author

@sean-perkins I added that property as you said but then it causes further issues with the page transitions.

Simulator.Screen.Recording.-.iPhone.12.-.2021-11-30.at.17.30.01.mp4

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Nov 30, 2021
@sean-perkins
Copy link
Contributor

@milanharia thanks for getting back to us quickly.

With that change resolving the flickering of the tabs, I believe the new issue now overlaps with a few other known issues in the React router implementation.

#23013 (individual tab pages being destroyed)
#20219 (transitions)

& the transition issue can also be found here:

I'll have to consult with the team on when we want to slate reworking the routers.

In the interim, while not ideal, you can turn off animations just on the top-level outlet when navigating between Home and tabs.

@milanharia
Copy link
Author

@sean-perkins Thanks for the response. I can turn off animations for the Home > Tabs navigation, however, this still leaves the issue of the tab pages flashing on tab switch. Also, I am under the understanding that this ionPage prop is meant for IonRouterOutlets that are rendered by a parent Route component:

App.tsx:

const App: React.FC = () => (
  <IonRouterOutlet>
    <Route path="/sub1" component={Sub1Outlet}  />
    <Route path="/sub2" component={Sub2Outlet} />
  </IonRouterOutlet>
);

Sub1Outlet.tsx:

const Sub1Outlet: React.FC = () =>  (
    <IonRouterOutlet ionPage>
      <Route path="/sub1" exact={true} 
        render={() => <Redirect to="/sub1/page" />} />
      <Route path="/sub1/page" component={Page1} exact={true} />
    </IonRouterOutlet>
  );

Sub2Outlet.tsx:

const Sub2Outlet: React.FC = () =>  (
    <IonRouterOutlet ionPage>
      <Route path="/sub2" exact={true} 
        render={() => <Redirect to="/sub2/page" />} />
      <Route path="/sub2/page" component={Page2} exact={true} />
    </IonRouterOutlet>
  );

@liamdebeasi liamdebeasi removed this from the 6.0.0-rc.4 milestone Dec 6, 2021
@hellokingdom
Copy link

@liamdebeasi @sean-perkins With 6.0 being made final has this issue been rejected or does it depend on the work to rebuild routing?

Our app which is still in development flashes between each nested route change. We've added the ionPage prop which does stop the bottom tabs flickering but the rest of the IonPage flashes between route changes.

It would seem our only solution now is to drop the nested routes and manually handle hiding the tabs once logged in.

@liamdebeasi
Copy link
Contributor

We are still interested in resolving this issue. The issue here seems to be a combination of quirks in Ionic React and some best practices not being followed in the sample app, but we'll take a closer look to get a better sense of what needs to change.

@milanharia
Copy link
Author

@liamdebeasi is it not possible to revert whatever change broke the tab switching between Ionic6-beta5 and Ionic6-rc1 as a temporary solution? I feel this issue could impact a lot of people who are upgrading from Ionic5 to Ionic6. If you cannot do this, the workaround of only having one IonRouterOutlet and manually hiding the tab bar on the pages you do not want to see them should potentially be documented in the breaking changes.

@hellokingdom
Copy link

@liamdebeasi Thank you for the update, in the meantime I have merged our nested outlets and used state to hide and show the tabs when required.

@sean-perkins
Copy link
Contributor

Hello everyone 👋 I'm still actively debugging this issue and can confirm that regardless of setting ionPage on the router outlet, this is still an issue that exists.

While tracing the issue, removing this line fixes the flickering issue between tab navigations:

enteringEl.classList.add('ion-page-invisible');

For some reason, when navigating between tabs when using nested outlets, the parent outlet is transitioning, even though the navigation is occurring in a child outlet inside of it (the parent outlet is already visible/active).

I'll need to discuss more with the team this week. I'm uncertain if the outlet should be even committing those changes when navigating between tabs. Likely this issue has existed for some time, but hasn't been a problem due to Stencil's hydration behavior.

@sean-perkins
Copy link
Contributor

Hello everyone, I have an open PR that addresses this issue and improves the behavior of nested router outlets.

You can test with the dev build here:

npm i @ionic/react@6.0.5-dev.1643392037.29a4e7f @ionic/react-router@6.0.5-dev.1643392037.29a4e7f

I have confirmed the fix in both the reproduction app and the Ionic React conference app.

@milanharia when testing your reproduction app, you will need to address a breaking change in V6. In your index.tsx, import and call setupIonicReact.

import { setupIonicReact } from '@ionic/react';

setupIonicReact({});

@ionitron-bot
Copy link

ionitron-bot bot commented Mar 2, 2022

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 Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: react @ionic/react package type: bug a confirmed bug report v6 issues specific to Framework v6
Projects
None yet
Development

No branches or pull requests

5 participants