custom clear function

This commit is contained in:
SpikeHD
2022-06-02 17:04:20 -07:00
parent 5aaa85939c
commit 5acd9b54d0
3 changed files with 18 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ interface IProps {
readonly?: boolean
placeholder?: string
folder?: boolean
customClearBehaviour?: () => void
}
interface IState {
@@ -95,6 +96,7 @@ export default class DirInput extends React.Component<IProps, IState> {
if (this.props.onChange) this.props.onChange(text)
}}
customClearBehaviour={this.props.customClearBehaviour}
/>
<div className="FileSelectIcon" onClick={this.handleIconClick}>
<img src={File} />

View File

@@ -11,6 +11,7 @@ interface IProps {
readOnly?: boolean;
id?: string;
clearable?: boolean;
customClearBehaviour?: () => void;
style?: {
[key: string]: any;
}
@@ -51,6 +52,10 @@ export default class TextInput extends React.Component<IProps, IState> {
{
this.props.clearable ?
<div className="TextClear" onClick={() => {
// Run custom behaviour first
console.log('cleared')
if (this.props.customClearBehaviour) return this.props.customClearBehaviour()
this.setState({ value: '' })
if (this.props.onChange) this.props.onChange('')