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

Context menu now works on sortableTable with no selection #5206

Merged
merged 2 commits into from
Oct 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 () {
Copy link
Member Author

@bsclifton bsclifton Oct 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and the change in addEditBookmarkHanger.js are changes I missed when originally doing that control, which was submitted with #5118

Focus is now properly set to the title input box when the modal launches (no issue had been filed yet)

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
19 changes: 17 additions & 2 deletions 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 @@ -248,7 +253,9 @@ class SortableTable extends React.Component {
(this.props.rowObjects.size > 0 || this.props.rowObjects.length > 0)
? (typeof this.props.rowObjects.toJS === 'function'
? this.props.rowObjects.get(index).toJS()
: this.props.rowObjects[index])
: (typeof this.props.rowObjects[index].toJS === 'function'
? this.props.rowObjects[index].toJS()
: this.props.rowObjects[index]))
: row

// Allow parent control to optionally specify context
Expand All @@ -261,9 +268,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