-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(Search): add handling of html input props #1442
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1442 +/- ##
==========================================
- Coverage 99.74% 99.74% -0.01%
==========================================
Files 141 141
Lines 2364 2363 -1
==========================================
- Hits 2358 2357 -1
Misses 6 6
Continue to review full report at Codecov.
|
I think we need to implement the mechanism that the Input itself implements, so that all HTML We can pull this list of HTML input props out of import { getHTMLInputProps } from '../lib'
const htmlInputProps = getHTMLInputProps(props) |
Makes sense to me. Will implement it. |
const value = _.get(e, 'target.value') | ||
|
||
const { onChange } = this.props | ||
if (onChange) onChange(e, { ...this.props, value }) |
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.
Cruft. handleChange
will be called only if onChange
defined.
src/lib/htmlInputPropsUtils.js
Outdated
|
||
export const htmlInputPropNames = [...htmlInputProps, ...htmlInputEvents] | ||
|
||
export const omitHTMLInputProps = (props, htmlProps = htmlInputPropNames) => _.omit(props, htmlProps) |
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.
Lodash has perf issues with _.omit
and it is also planned to be removed in v5, #864 . How about we move these two pick/omit methods into a single reduce that returns a pair of objects? Something like:
const [htmlInputProps, rest] = partitionHTMLInputProps(props)
Given:
const htmlInputProps = ['selected', ...]
const getHTMLInputProps = props => htmlInputProps.reduce((acc, next) => {
acc[+!(next in props)] = props[next]
return acc
}, [])
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.
Good suggestion, will make it 👍
Released in |
Fixes #1437.