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: Property 'inputType' does not exist on type 'Event' #28517

Closed
dehoward opened this issue Mar 7, 2024 · 5 comments
Closed

Bug: Property 'inputType' does not exist on type 'Event' #28517

dehoward opened this issue Mar 7, 2024 · 5 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@dehoward
Copy link

dehoward commented Mar 7, 2024

React version: 18.0.0

Steps To Reproduce

image

create an onChange handler for an input and try to access event.nativeEvent.inputType

Link to code example:

https://playcode.io/1790904

The current behavior

Doesn't allow type

The expected behavior

Should allow property access

@dehoward dehoward added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Mar 7, 2024
@HermanBide
Copy link

can i work on this if it has not been assigned to anyone?

@yezhonghu0503
Copy link

can i work on this if it has not been assigned to anyone?

why not?

@HermanBide
Copy link

HermanBide commented Mar 8, 2024

@dehoward @yezhonghu0503 I dont see the the object you are passing in the onclick function but im guessing the inputType key is present. looks like you are trying to get the key-value pair but its not directly available. i would write a condition to check if the inputType property exists before accessing it. Here's how you can modify this code.

import React from 'react';

export default function App() {
  const handleChange = (event) => {
    if (event.nativeEvent && event.nativeEvent.inputType) {
      console.log(JSON.stringify(event.nativeEvent.inputType));
    } else {
      console.log('inputType property not available');
    }
  };

  return (
    <div className='App'>
      <input onChange={handleChange} />
    </div>
  );
}

let me know if this fixes the bug.

@apurvak3
Copy link

apurvak3 commented Mar 8, 2024

I guess we have to ensure that the event object is of the correct type (InputEvent) before accessing the inputType property.

@Gaurav896260
Copy link

do you guys still have an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

5 participants