Skip to content

Commit

Permalink
Reader sidebar: fix add input
Browse files Browse the repository at this point in the history
  • Loading branch information
bluefuton committed Jan 11, 2016
1 parent 759c2ff commit 19629f7
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions client/reader/sidebar/menu.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* External Dependencies
*/
const React = require( 'react' ),
classNames = require( 'classnames' );
import React from 'react';
import classNames from 'classnames';

/**
* Internal Dependencies
*/
const Gridicon = require( 'components/gridicon' ),
Button = require( 'components/button' ),
Count = require( 'components/count' );
import Gridicon from 'components/gridicon';
import Button from 'components/button';
import Count from 'components/count';

const SidebarMenu = React.createClass( {

Expand Down Expand Up @@ -70,22 +70,24 @@ const SidebarMenu = React.createClass( {
},

toggleAdd: function() {
this.refs.menuAddInput.focus();
this.setState( { isAdding: ! this.state.isAdding } );
},

handleAddKeyDown: function() {
var inputValue = React.findDOMNode( this.refs.menuAddInput ).value;
if ( event.keyCode === 13 ) {
handleAddKeyDown: function( event ) {
const inputValue = this.refs.menuAddInput.value;
if ( event.keyCode === 13 && inputValue.length > 0 ) {
event.preventDefault();
this.props.onAddSubmit( inputValue );
React.findDOMNode( this.refs.menuAddInput ).value = '';
this.refs.menuAddInput.value = '';
this.toggleAdd();
}
},

renderAdd: function() {
return(
<div className="sidebar-menu__add-item">
<Button compact className="sidebar-menu__add-button" onClick={ this.toggleAdd }>Add</Button>
<Button compact className="sidebar-menu__add-button" onClick={ this.toggleAdd }>{ this.translate( 'Add' ) }</Button>

<div className="sidebar-menu__add">
<input
Expand Down Expand Up @@ -123,4 +125,4 @@ const SidebarMenu = React.createClass( {
}
} );

module.exports = SidebarMenu;
export default SidebarMenu;

0 comments on commit 19629f7

Please sign in to comment.