ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

bug: react, parameterized routes causing cloned elements to be misplaced

Open ckubitza opened this issue 1 year ago • 3 comments

Prerequisites

Ionic Framework Version

  • [ ] v4.x
  • [ ] v5.x
  • [X] v6.x
  • [ ] Nightly

Current Behavior

Using react. When going from a page to the same page (with a different parameter) an IonInput is jumping to the right while the page transition is active.

bug-screencast

Expected Behavior

The IonInput should not jump.

Steps to Reproduce

Have an IonInput on a page with a route parameter and navigate (by routerLink) to the same page with another parameter value.

Code Reproduction URL

https://github.com/ckubitza/ionic-input-page-transition-bug

Ionic Info

Ionic:

Ionic CLI : 6.19.1 Ionic Framework : @ionic/react 6.1.6

Capacitor:

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

Utility:

cordova-res : 0.15.4 native-run : 1.6.0

System:

NodeJS : v16.14.0 npm : 8.3.1 OS : Windows 10

Additional Information

From my observations, the IonInput component accidently has two native inputs inside while the transition is happening (you can break execution on ionViewWillEnter to see it).

duplicate-input

ckubitza avatar May 19 '22 15:05 ckubitza

Thanks for the issue. I can reproduce this, but I still need to dig deeper to see why this is happening.

liamdebeasi avatar May 23 '22 13:05 liamdebeasi

This appears to be the culprit: https://github.com/ionic-team/ionic-framework/blob/7b10fa6476c2c2896c6810c57b3160f8c8896faa/packages/react-router/src/ReactRouter/StackManager.tsx#L230-L234

When we transition to another instance of the same component @ionic/react-router attempts to clone the DOM nodes. This results in a duplicate input element inside of ion-input. This bug only impacts parameterized routes as far as I can tell.

liamdebeasi avatar Jul 08 '22 15:07 liamdebeasi

@liamdebeasi Could you help me understand, what's the design choice for cloning the page element for transitions to the same component?

To me, it seems weird to have a page leave, and the same page with all the same elements and state of those elements also come back in.

puopg avatar Jul 15 '22 15:07 puopg

Hey there,

Apologies for the delay. This issue was resolved in https://github.com/ionic-team/ionic-framework/pull/28616. The fix is available in Ionic 7.5.8, so I am going to close this.

liamdebeasi avatar Dec 14 '23 21:12 liamdebeasi

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[bot] avatar Jan 13 '24 22:01 ionitron-bot[bot]