Skip to content

Conversation

@splatonov92
Copy link

Describe the issue/change

Any component containing value props can not be passed as customInput property. Despite the fact that typing prohibits passing the customInput with value, number_format_base passes all props including value to customInput.

Add CodeSandbox link to illustrate the issue (If applicable)

Describe specs for failing cases if this is an issue (If applicable)

Describe the changes proposed/implemented in this PR

  • fix customInput type
  • remove @ts-ignore directive

Link Github issue if this PR solved an existing issue

Example usage (If applicable)

Screenshot (If applicable)

Please check which browsers were used for testing

  • Chrome
  • Chrome (Android)
  • Safari (OSX)
  • Safari (iOS)
  • Firefox
  • Firefox (Android)

src/types.ts Outdated
Omit<InputAttributes, keyof BaseType> &
Omit<BaseType, keyof Props | 'ref'> & {
customInput?: React.ComponentType<BaseType>;
customInput?: React.ComponentType<React.InputHTMLAttributes<HTMLInputElement> & React.RefAttributes<HTMLInputElement>>;
Copy link
Owner

@s-yadav s-yadav Feb 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will force the customInput to be type of Input element. While custom Input can be any component, and the NumberFormatProps inherits from there.
Please check on number_format.spec.tsx, it must be failing.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me try to fix it, may be I need to rewrite a couple of types


export type InputAttributes = Omit<
React.InputHTMLAttributes<HTMLInputElement>,
'defaultValue' | 'value' | 'children'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FMI: why do you need to omit 'defaultValue' | 'value' from InputAttributes?

@splatonov92 splatonov92 force-pushed the fix-customInput-type branch from 99d26af to 634c28c Compare August 18, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants