diff --git a/internal_packages/composer/lib/contenteditable-component.cjsx b/internal_packages/composer/lib/contenteditable-component.cjsx index b4bc9068f..60cfb7f07 100644 --- a/internal_packages/composer/lib/contenteditable-component.cjsx +++ b/internal_packages/composer/lib/contenteditable-component.cjsx @@ -481,7 +481,10 @@ class ContenteditableComponent extends React.Component # Don't bother computing client rects if no scroll method has been provided else if @props.onScrollTo - rect = @_getRangeInScope().getBoundingClientRect() + rangeInScope = @_getRangeInScope() + return unless rangeInScope + + rect = rangeInScope.getBoundingClientRect() if @_isEmptyBoudingRect(rect) rect = @_getSelectionRectFromDOM(selection) @@ -763,31 +766,24 @@ class ContenteditableComponent extends React.Component toolbarPos: toolbarPos linkToModify: @_linkHoveringOver editAreaWidth: editAreaWidth + + else if not @_selection? or @_selection.isCollapsed + @_hideToolbar() + else - if not @_selection? or @_selection.isCollapsed + rect = @_getRangeInScope()?.getBoundingClientRect() + if not rect or @_isEmptyBoudingRect(rect) @_hideToolbar() else - if @_selection.isCollapsed - linkRect = linksInside[0].getBoundingClientRect() - isEmptyRect = @_isEmptyBoudingRect(linkRect) - [left, top, editAreaWidth, toolbarPos] = @_getToolbarPos(linkRect) - else - selectionRect = @_getRangeInScope().getBoundingClientRect() - isEmptyRect = @_isEmptyBoudingRect(selectionRect) - [left, top, editAreaWidth, toolbarPos] = @_getToolbarPos(selectionRect) - - if isEmptyRect - @setState - toolbarVisible: false - else - @setState - toolbarVisible: true - toolbarMode: "buttons" - toolbarTop: top - toolbarLeft: left - toolbarPos: toolbarPos - linkToModify: null - editAreaWidth: editAreaWidth + [left, top, editAreaWidth, toolbarPos] = @_getToolbarPos(rect) + @setState + toolbarVisible: true + toolbarMode: "buttons" + toolbarTop: top + toolbarLeft: left + toolbarPos: toolbarPos + linkToModify: null + editAreaWidth: editAreaWidth _selectionInScope: (selection) => return false if not selection? diff --git a/internal_packages/message-list/lib/message-list.cjsx b/internal_packages/message-list/lib/message-list.cjsx index fe87651e0..f34e78ae9 100755 --- a/internal_packages/message-list/lib/message-list.cjsx +++ b/internal_packages/message-list/lib/message-list.cjsx @@ -383,7 +383,9 @@ class MessageList extends React.Component _onChildScrollRequest: ({messageId, rect}={}) => return if @_draftScrollInProgress if messageId - @refs.messageWrap.scrollTo(@_getMessageContainer(messageId), { + messageElement = @_getMessageContainer(messageId) + return unless messageElement + @refs.messageWrap.scrollTo(messageElement, { position: ScrollRegion.ScrollPosition.Visible }) else if rect diff --git a/internal_packages/thread-list/lib/thread-list.cjsx b/internal_packages/thread-list/lib/thread-list.cjsx index bb155fcd6..5ac362cff 100644 --- a/internal_packages/thread-list/lib/thread-list.cjsx +++ b/internal_packages/thread-list/lib/thread-list.cjsx @@ -232,6 +232,8 @@ class ThreadList extends React.Component # Additional Commands _onStarItem: => + return unless ThreadListStore.view() + if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread Actions.toggleStarFocused() else if ThreadListStore.view().selection.count() > 0 @@ -240,6 +242,8 @@ class ThreadList extends React.Component Actions.toggleStarFocused() _onArchive: => + return unless ThreadListStore.view() + if WorkspaceStore.layoutMode() is "list" and WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread Actions.archive() else if ThreadListStore.view().selection.count() > 0