fix(sidebar): Add minor tweaks to sidebar behavior:

- Add default prop to DisclosureTriangle to eliminate warning
- Prevent from firing a new DestroyCategoryTask if category already is
deleted
- Update onBlur event to not close input if I click on the add button
This commit is contained in:
Juan Tejada 2015-11-24 11:06:09 -08:00
parent aa1f87bdde
commit f48875d681
3 changed files with 15 additions and 3 deletions

View file

@ -34,7 +34,8 @@ class AccountSidebarSection extends React.Component
_createItemButton: ({label}) ->
<div
className="add-item-button"
onClick={@_onCreateButtonClicked.bind(@, label)}>
onMouseDown={@_onCreateButtonMouseDown}
onMouseUp={@_onCreateButtonClicked.bind(@, label)}>
<RetinaImg
url="nylas://account-sidebar/assets/icon-sidebar-addcategory@2x.png"
style={height: 14, width: 14}
@ -59,7 +60,7 @@ class AccountSidebarSection extends React.Component
className="input-bordered add-item-input"
autoFocus={true}
onKeyDown={_.partial @_onInputKeyDown, _, section}
onBlur={ => @setState(showCreateInput: false) }
onBlur={@_onInputBlur}
placeholder={placeholder}/>
</div>
</span>
@ -87,9 +88,16 @@ class AccountSidebarSection extends React.Component
components
_onCreateButtonMouseDown: =>
@_clickingCreateButton = true
_onCreateButtonClicked: (sectionLabel) =>
@_clickingCreateButton = false
@setState(showCreateInput: not @state.showCreateInput)
_onInputBlur: =>
@setState(showCreateInput: false) if not @_clickingCreateButton
_onInputKeyDown: (event, section) =>
if event.key is 'Escape'
@setState(showCreateInput: false)

View file

@ -143,6 +143,7 @@ class AccountSidebarStore extends NylasStore
_destroyCategory: (sidebarItem) ->
category = sidebarItem.mailViewFilter.category
return if category.isDeleted is true
Actions.queueTask(new DestroyCategoryTask({category}))
_itemUnreadCount: (category) =>

View file

@ -6,7 +6,10 @@ class DisclosureTriangle extends React.Component
@propTypes:
collapsed: React.PropTypes.bool
visible: React.PropTypes.bool
onToggleCollapsed: React.PropTypes.func.isRequired
onToggleCollapsed: React.PropTypes.func
@defaultProps:
onToggleCollapsed: ->
render: ->
classnames = "disclosure-triangle"