Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Context menu now works on sortableTable with no selection
Browse files Browse the repository at this point in the history
Also fixes: focus for new folder / edit folder / new bookmark now set properly

Fixes #5202

Auditors: @darkdh
  • Loading branch information
bsclifton authored and bbondy committed Oct 28, 2016
1 parent 1352fa1 commit 9c79085
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/renderer/components/addEditBookmarkHanger.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class AddEditBookmarkHanger extends ImmutableComponent {
get isFolder () {
return siteUtil.isFolder(this.props.currentDetail)
}
setDefaultFocus () {
this.bookmarkName.select()
this.bookmarkName.focus()
}
updateFolders (props) {
this.folders = siteUtil.getFolders(this.props.sites, props.currentDetail.get('folderId'))
}
Expand All @@ -71,8 +75,7 @@ class AddEditBookmarkHanger extends ImmutableComponent {
if (!this.props.isModal && !this.props.shouldShowLocation) {
this.onSave(false)
}
this.bookmarkName.select()
this.bookmarkName.focus()
this.setDefaultFocus()
}
onKeyDown (e) {
switch (e.keyCode) {
Expand Down
4 changes: 4 additions & 0 deletions js/components/addEditBookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ class AddEditBookmark extends ImmutableComponent {
onClose () {
windowActions.setBookmarkDetail()
}
componentDidMount () {
this.refs.bookmarkHanger.setDefaultFocus()
}
render () {
return <Dialog onHide={this.onClose} isClickDismiss>
<AddEditBookmarkHanger
ref='bookmarkHanger'
isModal
sites={this.props.sites}
currentDetail={this.props.currentDetail}
Expand Down
15 changes: 14 additions & 1 deletion js/components/sortableTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class SortableTable extends React.Component {
: this
: this
}
get nullSelection () {
return this.props.multiSelect
? this.stateOwner.state.selection.size === 0
: false
}
get multipleItemsSelected () {
return this.props.multiSelect
? this.stateOwner.state.selection.size > 1
Expand Down Expand Up @@ -261,9 +266,17 @@ class SortableTable extends React.Component {

// Bindings for multi-select-specific event handlers
if (this.props.multiSelect) {
rowAttributes.onContextMenu = this.onContextMenu
// Table supports multi-select
rowAttributes.onClick = this.onClick
if (this.nullSelection && this.hasContextMenu) {
// If nothing is selected yet, offer a default per-item context menu
rowAttributes.onContextMenu = this.props.onContextMenu.bind(this, handlerInput, this.props.contextMenuName)
} else {
// If items are selected we must use the multiple item handler
rowAttributes.onContextMenu = this.onContextMenu
}
} else {
// Table does not support multi-select
if (this.hasContextMenu) {
rowAttributes.onContextMenu = this.props.onContextMenu.bind(this, handlerInput, this.props.contextMenuName)
}
Expand Down
2 changes: 2 additions & 0 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ function siteDetailTemplateInit (siteDetail, activeFrame) {
} else if (multipleHistoryEntries) {
deleteLabel = 'deleteHistoryEntries'
}
} else {
deleteLabel = ''
}

const template = []
Expand Down

0 comments on commit 9c79085

Please sign in to comment.