nkbt / react-debounce-input

React component that renders Input with debounced onChange
MIT License
450 stars 61 forks source link

maxLength prop doesn't work #124

Closed hassanmehdi98 closed 4 years ago

hassanmehdi98 commented 4 years ago

maxLength prop on debounce input doesn't work

<DebounceInput
element={InputRightIcon}
iconName={`feather ${searchText ? "feather-x-circle" : "feather-search"}`}
value={searchText}
type="text"
onChange={e => this.handleSearchChange(e.target.value)}
placeholder="Search"
onSubmit={e => e.preventDefault()}
onIconClick={this.handleClearSearchClick}
debounceTimeout={500}
maxLength={255}
/>

I am still able to write more than 255 characters in the input field. Inspecting the element i did not found any maxlength property on the input from chrome inspector.

nkbt commented 4 years ago

All the props are passed through to the input element https://github.com/nkbt/react-debounce-input/blob/master/src/Component.js#L214

I don't know why yours does not. Would be good if you can reproduce it in codepen/jsbin/codesandbox (you can clone https://codepen.io/nkbt/pen/VvmzLQ?editors=0010)

hassanmehdi98 commented 4 years ago

Closing this issue as i passed my custom element in element prop which caused this issue.