Skip to content

bug: In React, modals within the IonNav component cause input elements to become non-reactive. #28841

Closed as not planned

Description

@mhryshkin

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

If I try to render a modal within , any input element becomes non-reactive, e.g., onChange, onFocus and other events don't work.

Expected Behavior

Input elements work as expected and are reactive.

Steps to Reproduce

In the example below value will never change, onChange is not called if you type in the input.

import React, { useState } from 'react';
import { IonModal, IonNav } from '@ionic/react';

const NavLinkInnerModal = () => {
  const [value, setValue] = useState('');

  return (
    <IonModal isOpen={true}>
      <div>
        <input
          value={value}
          onChange={(e) => {
            alert('on change is called');
            setValue(e.target.value);
          }}
        />
        <div>Value - {value}</div>
      </div>
    </IonModal>
  );
};

function Example() {
  return <IonNav root={() => <NavLinkInnerModal />}></IonNav>;
}
export default Example;

Code Reproduction URL

https://stackblitz.com/edit/q1xwny?file=src%2Fmain.tsx,src%2Findex.tsx

Ionic Info

Ionic:

Ionic CLI : 7.1.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 7.5.1

Capacitor:

Capacitor CLI : 5.3.0
@capacitor/android : 5.5.0
@capacitor/core : 5.5.0
@capacitor/ios : 5.5.0

Utility:

cordova-res : not installed globally
native-run (update available: 2.0.0) : 1.7.3

System:

NodeJS : v18.16.1 (/usr/local/bin/node)
npm : 9.5.1
OS : macOS Monterey

───────────────────────────────────────────────

 Ionic CLI update available: 7.1.1 → 7.1.5
     Run npm i -g @ionic/cli to update

Additional Information

This issue is a significant blocker for using the very helpful IonNav component.

Activity

  1. self-assigned this
    on Jan 17, 2024
  2. liamdebeasi commented on Jan 17, 2024

    @liamdebeasi
    Contributor

    Thanks for the issue. I am going to close this as a duplicate of #27843.

  3. removed their assignment
    on Jan 17, 2024
  4. mhryshkin commented on Jan 17, 2024

    @mhryshkin
    Author

    Thanks for the issue. I am going to close this as a duplicate of #27843.

    @liamdebeasi ok, thanks, i've found a workaround, gonna share.

  5. ionitron-bot commented on Feb 16, 2024

    @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.

  6. locked and limited conversation to collaborators on Feb 16, 2024
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

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions