File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import React from 'react'
22import PropTypes from 'prop-types'
3- import EditableLabel from 'components/widgets/EditableLabel'
4-
3+ import InlineInput from 'components/widgets/InlineInput'
54import { Title , LaneHeader , RightContent } from 'styles/Base'
65import LaneMenu from './LaneHeader/LaneMenu'
76
@@ -13,7 +12,7 @@ const LaneHeaderComponent = ({
1312 < LaneHeader onDoubleClick = { onDoubleClick } >
1413 < Title style = { titleStyle } >
1514 { editLaneTitle ?
16- < EditableLabel value = { title } border inline placeholder = { t ( 'placeholder.title' ) } onChange = { updateTitle } /> :
15+ < InlineInput value = { title } border placeholder = { t ( 'placeholder.title' ) } onChange = { updateTitle } /> :
1716 title
1817 }
1918 </ Title >
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import PropTypes from 'prop-types'
3+ import { InlineInput } from 'styles/Base'
4+
5+ class InlineInputController extends React . Component {
6+ onFocus = ( e ) => e . target . select ( )
7+
8+ // This is the way to select all text if mouse clicked
9+ onMouseDown = ( e ) => {
10+ if ( document . activeElement != e . target ) {
11+ e . preventDefault ( )
12+ this . refInput . focus ( )
13+ }
14+ }
15+
16+ onBlur = ( ) => {
17+ this . updateValue ( )
18+ }
19+
20+ onKeyDown = ( e ) => {
21+ if ( e . keyCode == 13 ) {
22+ this . refInput . blur ( )
23+ e . preventDefault ( )
24+ }
25+ if ( e . keyCode == 27 ) {
26+ this . refInput . blur ( )
27+ e . preventDefault ( )
28+ }
29+ }
30+
31+ getValue = ( ) => this . refInput . value
32+
33+ updateValue = ( ) => {
34+ if ( this . getValue ( ) != this . props . value ) {
35+ this . props . onChange ( this . getValue ( ) )
36+ }
37+ }
38+
39+ render ( ) {
40+ const { autoFocus, value, placeholder} = this . props
41+
42+ return < InlineInput
43+ ref = { ref => ( this . refInput = ref ) }
44+ onMouseDown = { this . onMouseDown }
45+ onFocus = { this . onFocus }
46+ onBlur = { this . onBlur }
47+ onKeyDown = { this . onKeyDown }
48+ placeholder = { value . length == 0 ? false : placeholder }
49+ defaultValue = { value }
50+ />
51+ }
52+ }
53+
54+ InlineInputController . defaultProps = {
55+ onChange : ( ) => { } ,
56+ placeholder : '' ,
57+ value : '' ,
58+ }
59+
60+ InlineInputController . propTypes = {
61+ onChange : PropTypes . func ,
62+ placeholder : PropTypes . string ,
63+ value : PropTypes . string
64+ }
65+
66+ export default InlineInputController
Original file line number Diff line number Diff line change @@ -257,3 +257,22 @@ export const NewLaneButtons = styled.div`
257257export const CardForm = styled . div `
258258 background-color: #e3e3e3;
259259`
260+
261+ export const InlineInput = styled . textarea `
262+ overflow: hidden;
263+ word-wrap: break-word;
264+ resize: none;
265+ width: 100%;
266+ height: 28px;
267+ line-height: 20px;
268+ background-color: transparent;
269+ box-shadow: none;
270+ border-radius: 3px;
271+ border: 0;
272+ padding: 4px 8px;
273+ outline: 0;
274+ &:focus {
275+ background-color: white;
276+ box-shadow: inset 0 0 0 2px #0079bf;
277+ }
278+ `
You can’t perform that action at this time.
0 commit comments