Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
WIP: reset button
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Mar 5, 2016
1 parent 149cd68 commit 0d37143
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
7 changes: 4 additions & 3 deletions frontend/src/main/web/src/components/EditableText.js
Expand Up @@ -71,8 +71,6 @@ class EditableText extends Component {
!children && classes.text.placeholder
)
}
const emptyText = editable ? placeholder : emptyReadOnlyText
const text = children || emptyText
if (editable && editing) {
return (
<TextInput
Expand All @@ -82,9 +80,12 @@ class EditableText extends Component {
placeholder={placeholder}
theme={classes.textInput}
ref={(ref) => this.textInput = ref}
defaultValue={children} />
value={children}
/>
)
}
const emptyText = editable ? placeholder : emptyReadOnlyText
const text = children || emptyText
return (
<Row theme={textStateClasses} align='start' onClick={::this.handleClick}>
{text}
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/main/web/src/components/TextInput.jsx
Expand Up @@ -2,6 +2,7 @@ import React, { Component, PropTypes } from 'react'
import ReactDOM from 'react-dom'
import TextareaAutosize from 'react-textarea-autosize'
import { flattenClasses } from 'zanata-ui'
import { debounce } from 'lodash'

const classes = {
base: {
Expand All @@ -27,16 +28,20 @@ const classes = {
}

class TextInput extends Component {

_onBlur (e) {
const { onBlur } = this.props
if (onBlur) onBlur(e)
if (onBlur) {
onBlur(e)
}
}
_onChange (e) {
_updateText (e) {
const { onChange, onChangeText } = this.props
if (onChangeText) onChangeText(e.target.value)
if (onChange) onChange(e)
}
_onChange (e) {
debounce(this._updateText(e), 300)
}
_onFocus (e) {
const { clearTextOnFocus, onFocus, selectTextOnFocus } = this.props
const node = ReactDOM.findDOMNode(this)
Expand Down

0 comments on commit 0d37143

Please sign in to comment.