Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

fix(Input): remove duplcated 'onChange' handling #310

Merged
merged 3 commits into from
Oct 5, 2018

Conversation

kuzhelov
Copy link
Contributor

@kuzhelov kuzhelov commented Oct 4, 2018

Currently for each change of the input value we have onChange handler logic being called twice. This is happening due to the same event handling function is provided both for <input> DOM element, as well as for the wrapping component (default is <div>):

renderComponent({ ElementType, classes, styles, variables }) {
   ...

    return (
      <ElementType className={classes.root} {...restProps} onChange={onChange}>  // <----- HERE
        {createHTMLInput(type, {
          defaultProps: htmlInputProps, // <------ AND HERE, as htmlInputProps contain 'onChange' one
          overrideProps: {
            className: inputClasses,
            ref: this.handleInputRef,
          },
        })}

image

@codecov
Copy link

codecov bot commented Oct 4, 2018

Codecov Report

Merging #310 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #310      +/-   ##
==========================================
- Coverage   89.54%   89.54%   -0.01%     
==========================================
  Files          62       62              
  Lines        1177     1176       -1     
  Branches      175      152      -23     
==========================================
- Hits         1054     1053       -1     
  Misses        121      121              
  Partials        2        2
Impacted Files Coverage Δ
src/components/Input/Input.tsx 84.61% <ø> (-0.3%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ca9cfd...b295752. Read the comment docs.

@kuzhelov kuzhelov added 🚀 ready for review 🧰 fix Introduces fix for broken behavior. labels Oct 4, 2018
Copy link
Collaborator

@bmdalex bmdalex left a comment

Choose a reason for hiding this comment

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

looks good @mnajdova @alinais can one of you approve too?

const inputClasses = classes.input

return (
<ElementType className={classes.root} {...restProps} onChange={onChange}>
<ElementType className={classes.root} {...restProps}>
Copy link
Contributor

@mnajdova mnajdova Oct 4, 2018

Choose a reason for hiding this comment

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

+1

@kuzhelov kuzhelov merged commit 5fe12bf into master Oct 5, 2018
@layershifter layershifter deleted the fix/input-remove-duplicated-onchange-invocation branch November 9, 2018 09:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🧰 fix Introduces fix for broken behavior. ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants