diff --git a/js/about/bookmarks.js b/js/about/bookmarks.js index 5d8c69d8e5b..b459561ebbc 100644 --- a/js/about/bookmarks.js +++ b/js/about/bookmarks.js @@ -62,6 +62,11 @@ class BookmarkFolderItem extends React.Component { true) } } + clearSelection () { + if (this.props.onClearSelection) { + this.props.onClearSelection() + } + } // NOTE: both folders AND bookmarks can be dropped here onDrop (e) { this.setState({ @@ -74,10 +79,12 @@ class BookmarkFolderItem extends React.Component { bookmarkData.forEach((bookmark) => { this.moveBookmark(e, bookmark) }) + this.clearSelection() return } this.moveBookmark(e, bookmarkData) + this.clearSelection() } } render () { @@ -137,6 +144,7 @@ class BookmarkFolderList extends ImmutableComponent { { this.props.isRoot ? this.props.isRoot && bookmarkFolder.get('parentFolderId') === -1 ? null - : { this.moveBookmark(e, bookmark, siteDetail) }) + this.clearSelection() return } this.moveBookmark(e, bookmarkData, siteDetail) + this.clearSelection() } } + clearSelection () { + this.refs.bookmarkTable.clearSelection() + } render () { const props = !this.props.draggable ? { onDragStart: this.onDragStart, @@ -312,6 +328,7 @@ class BookmarksList extends ImmutableComponent { } return
, 'Last Visited' @@ -348,6 +365,8 @@ class AboutBookmarks extends React.Component { this.onClearSearchText = this.onClearSearchText.bind(this) this.importBrowserData = this.importBrowserData.bind(this) this.addBookmarkFolder = this.addBookmarkFolder.bind(this) + this.onClick = this.onClick.bind(this) + this.clearSelection = this.clearSelection.bind(this) this.state = { bookmarks: Immutable.List(), bookmarkFolders: Immutable.Map(), @@ -377,6 +396,19 @@ class AboutBookmarks extends React.Component { search: '' }) } + onClick (e) { + // Determine if click was on sortableTable + let targetElement = e.target + while (targetElement) { + if (targetElement.tagName === 'TBODY') { + return + } + targetElement = targetElement.parentNode + } + + // Click was not a child element of sortableTable; clear selection + this.clearSelection() + } searchedBookmarks (searchTerm, bookmarks) { return bookmarks.filter((bookmark) => { const title = bookmark.get('customTitle') + bookmark.get('title') + bookmark.get('location') @@ -396,6 +428,9 @@ class AboutBookmarks extends React.Component { }) aboutActions.showAddBookmarkFolder(newFolder) } + clearSelection () { + this.refs.bookmarkList.clearSelection() + } componentDidMount () { this.refs.bookmarkSearch.focus() } @@ -415,14 +450,16 @@ class AboutBookmarks extends React.Component {
-
+
- bookmark.get('parentFolderId') === -1)} allBookmarkFolders={this.state.bookmarkFolders} isRoot @@ -431,6 +468,7 @@ class AboutBookmarks extends React.Component {