Skip to content
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(input): add max-length prop to top-level #3613

Merged
merged 5 commits into from Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions documentation-site/components/yard/config/input.ts
Expand Up @@ -193,6 +193,12 @@ export const inputProps = {
description: 'max value when used as input type=number',
hidden: true,
},
maxLength: {
value: undefined,
type: PropTypes.Number,
description: 'max number of characters accepted in the input element',
hidden: true,
},
...pick(changeHandlers, [
'onBlur',
'onKeyDown',
Expand Down
1 change: 1 addition & 0 deletions src/input/__tests__/__snapshots__/base-input.test.js.snap
Expand Up @@ -41,6 +41,7 @@ Object {
"id": undefined,
"inputMode": "text",
"max": undefined,
"maxLength": undefined,
"min": undefined,
"name": "",
"onBlur": [Function],
Expand Down
1 change: 1 addition & 0 deletions src/input/__tests__/__snapshots__/input.test.js.snap
Expand Up @@ -17,6 +17,7 @@ Object {
"id": undefined,
"inputMode": "text",
"max": undefined,
"maxLength": undefined,
"min": undefined,
"name": "",
"onBlur": [Function],
Expand Down
Expand Up @@ -68,6 +68,7 @@ Object {
"id": undefined,
"inputMode": "text",
"max": undefined,
"maxLength": undefined,
"min": undefined,
"name": "",
"onBlur": [Function],
Expand Down
1 change: 1 addition & 0 deletions src/input/base-input.js
Expand Up @@ -328,6 +328,7 @@ class BaseInput<T: EventTarget> extends React.Component<
disabled={this.props.disabled}
id={this.props.id}
inputMode={this.props.inputMode}
maxLength={this.props.maxLength}
name={this.props.name}
onBlur={this.onBlur}
onChange={this.props.onChange}
Expand Down
1 change: 1 addition & 0 deletions src/input/types.js
Expand Up @@ -124,6 +124,7 @@ export type BaseInputPropsT<T> = {|
clearable?: boolean,
/** If undefined or true, clears the input when the Escape button is pressed with the input focused. True by default. */
clearOnEscape?: boolean,
maxLength?: number,
onClear?: (e: SyntheticEvent<T>) => mixed,
overrides: BaseInputComponentsT,
placeholder?: string,
Expand Down
1 change: 0 additions & 1 deletion src/pin-code/pin-code.js
Expand Up @@ -80,7 +80,6 @@ export default class PinCode extends React.Component<PropsT, StateT> {
inputMode="numeric"
inputRef={this._inputRefs.ref(i)}
key={i}
maxLength="1"
name={this.props.name}
onBlur={() => this.setState({hasFocus: false})}
onFocus={() => this.setState({hasFocus: true})}
Expand Down
1 change: 1 addition & 0 deletions src/textarea/__tests__/__snapshots__/textarea.test.js.snap
Expand Up @@ -17,6 +17,7 @@ Object {
"id": undefined,
"inputMode": "text",
"max": undefined,
"maxLength": undefined,
"min": undefined,
"name": "",
"onBlur": [Function],
Expand Down