-
Notifications
You must be signed in to change notification settings - Fork 443
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
Pass event instead of value to Input's onChange callback #692
base: master
Are you sure you want to change the base?
Pass event instead of value to Input's onChange callback #692
Conversation
@@ -65,4 +65,16 @@ describe('Input test', () => { | |||
expect(w.find('.el-textarea__inner').first().prop('style').resize).toBe('both'); | |||
}); | |||
|
|||
it('onChange', (done) => { | |||
const updateValue = function(event) { | |||
expect(event.target).toBeInstanceOf(EventTarget); |
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.
I know that this is not perfect, but as SyntheticEvent is not a constructor, just a type, and that I don't really get an Event, I needed a way to make sure I was getting a SyntheticEvent rather than a string. Events have a target, so I didn't want to check on every single property. Any suggestion is welcome if you have a better idea.
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.
dInputelay
?
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.
Personally, I think it would be better that passing the event than the string. However this will change the API and other users will need to update their old code.
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 for the lazy response, passing the value string is an easy way to devs, I think we can pass additional parameter as SyntheticEvent
type.
If we change the first parameter to SyntheticEvent
, the other components which relies on Input
need rework to make sure onChange
event works.
Please do this, users who has already done their app can stay on an old release no ? |
This change will cause unexpected behavior since My solution is giving additional parameter as the native event, as |
Please makes sure these boxes are checked before submitting your PR, thank you!
master
branch.npm test
,npm run lint
andnpm run build
.Changes in this pull request