Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Expose `Popup`'s content Ref @sophieH29 ([#913](https://github.com/stardust-ui/react/pull/913))
- Fix `Button` Teams theme styles to use semibold weight @notandrew ([#829](https://github.com/stardust-ui/react/pull/829))
- Fix conflicts of generated names in Fela with FontAwesome @layershifter ([#951](https://github.com/stardust-ui/react/pull/951))
- Fix handleOnClear of Input by calling onChange callback when cleared @pajindal([#957](https://github.com/stardust-ui/react/pull/957))


### Documentation
- Add `Editable Area with Dropdown` prototype for mentioning people using `@` character (only available in development mode) @Bugaa92 ([#931](https://github.com/stardust-ui/react/pull/931))
Expand Down
10 changes: 7 additions & 3 deletions packages/react/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class Input extends AutoControlledComponent<ReactProps<InputProps>, InputState>

private handleIconOverrides = predefinedProps => ({
onClick: (e: React.SyntheticEvent) => {
this.handleOnClear()
this.handleOnClear(e)
this.inputRef.current.focus()
_.invoke(predefinedProps, 'onClick', e, this.props)
},
Expand All @@ -191,9 +191,13 @@ class Input extends AutoControlledComponent<ReactProps<InputProps>, InputState>
this.trySetState({ value })
}

private handleOnClear = () => {
private handleOnClear = (e: React.SyntheticEvent) => {
if (this.props.clearable) {
this.trySetState({ value: '' })
const value = ''

_.invoke(this.props, 'onChange', e, { ...this.props, value })

this.trySetState({ value })
}
}

Expand Down