mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Always return focus to the editor after a tab drop
This commit is contained in:
@@ -79,7 +79,10 @@ class TabView extends SortableList
|
||||
fromPane = $(rootView.find('.pane')[fromPaneIndex])
|
||||
fromEditor = fromPane.find('.editor').view()
|
||||
draggedTab = fromPane.find(".#{TabView.viewClass()} .sortable:eq(#{previousDraggedTabIndex})")
|
||||
return if draggedTab.is(droppedNearTab)
|
||||
|
||||
if draggedTab.is(droppedNearTab)
|
||||
fromEditor.focus()
|
||||
return
|
||||
|
||||
if fromPaneIndex == toPaneIndex
|
||||
droppedNearTab = @getSortableElement(event)
|
||||
@@ -90,6 +93,8 @@ class TabView extends SortableList
|
||||
fromEditor.focus()
|
||||
else
|
||||
toEditor = rootView.find(".pane:eq(#{toPaneIndex}) > .editor").view()
|
||||
unless @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()])
|
||||
if @containsEditSession(toEditor, fromEditor.editSessions[draggedTab.index()])
|
||||
fromEditor.focus()
|
||||
else
|
||||
fromEditor.moveEditSessionToEditor(draggedTab.index(), toEditor, droppedNearTab.index() + 1)
|
||||
toEditor.focus()
|
||||
|
||||
@@ -159,6 +159,28 @@ describe "TabView", ->
|
||||
expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt"
|
||||
|
||||
describe "dragging and dropping tabs", ->
|
||||
describe "when the tab is dropped onto itself", ->
|
||||
it "doesn't move the edit session and focuses the editor", ->
|
||||
expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt"
|
||||
|
||||
sortableElement = [tabs.find('.tab:eq(0)')]
|
||||
spyOn(tabs, 'getSortableElement').andCallFake -> sortableElement[0]
|
||||
event = $.Event()
|
||||
event.target = tabs[0]
|
||||
event.originalEvent =
|
||||
dataTransfer:
|
||||
data: {}
|
||||
setData: (key, value) -> @data[key] = value
|
||||
getData: (key) -> @data[key]
|
||||
|
||||
editor.hiddenInput.focusout()
|
||||
tabs.onDragStart(event)
|
||||
tabs.onDrop(event)
|
||||
|
||||
expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js"
|
||||
expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt"
|
||||
expect(editor.isFocused).toBeTruthy()
|
||||
|
||||
describe "when a tab is dragged from and dropped onto the same editor", ->
|
||||
it "moves the edit session, updates the order of the tabs, and focuses the editor", ->
|
||||
expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.js"
|
||||
|
||||
Reference in New Issue
Block a user