-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[core] refactor(InputGroup): improve interface #4441
[core] refactor(InputGroup): improve interface #4441
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good change but in its current state, it is a breaking change for anyone importing IInputGroupProps
(yes, that type is used in many places by consumers). I suggest you mark the current interface as /** @deprecated */
and introduce a new one called IInputGroupProps2
which we can migrate to in the next major version.
packages/timezone/src/components/timezone-picker/timezonePicker.tsx
Outdated
Show resolved
Hide resolved
@adidahiya Done with all the review issues, I also replaced Can you tell me what's the issue with Button and AnchorButton exactly? |
In the same way you've refactored |
@adidahiya I've checked the code and what you want can't be done with an interface, as ts will error with: |
@@ -94,6 +98,14 @@ export interface IControlledProps { | |||
value?: string; | |||
} | |||
|
|||
export interface IControlledProps2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry to revisit this -- why are you making this change to remove onChange
from the interface? you're Omit
ing those fields anyway in IInputGroupProps2
below..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of IControlledProps (as far I understand it) is to define the correct types we support, which is only value: string
on value
and defaultValue
props, however onChange
is compatible without any other change, so we're defining unnecessary properties (and not following the original typing which is React.ChangeEvent
not React.FormEventHandler
[even though React.ChangeEventHandler
could be used]).
So unless there's an specific reason so not use the native type, I don't see why it should be redefined.
@ejose19 yeah I think a |
Checklist
Changes proposed in this pull request:
This PR reduces the friction between InputGroup and HTMLInputElement by only replacing the properties that aren't supported
{ defaultValue: string[], value: string[] }
This has 2 benefits:
IInputGroupProps
instead ofIInputGroupProps & HTMLInputProps
(just like the rest of Blueprint components)onChange
when the function is declared in the prop