From 21e5f550c84deb2345f9b73d8c1d63eba9421a60 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Feb 2013 21:11:15 -0800 Subject: [PATCH] Assert editor receives focus after tab is dropped --- src/packages/tabs/lib/tab-view.coffee | 1 + src/packages/tabs/spec/tabs-spec.coffee | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/packages/tabs/lib/tab-view.coffee b/src/packages/tabs/lib/tab-view.coffee index b15fb40ef..99d171762 100644 --- a/src/packages/tabs/lib/tab-view.coffee +++ b/src/packages/tabs/lib/tab-view.coffee @@ -87,6 +87,7 @@ class TabView extends SortableList toIndex = droppedNearTab.index() toIndex++ if fromIndex > toIndex fromEditor.moveEditSessionToIndex(fromIndex, toIndex) + fromEditor.focus() else toPane = $(rootView.find('.pane')[toPaneIndex]) toEditor = toPane.find('.editor').view() diff --git a/src/packages/tabs/spec/tabs-spec.coffee b/src/packages/tabs/spec/tabs-spec.coffee index 31aff09e6..addbdda81 100644 --- a/src/packages/tabs/spec/tabs-spec.coffee +++ b/src/packages/tabs/spec/tabs-spec.coffee @@ -160,7 +160,7 @@ describe "TabView", -> describe "dragging and dropping tabs", -> describe "when a tab is dragged from and dropped onto the same editor", -> - it "moves the edit session and updates the order of the tabs", -> + 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" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.txt" @@ -174,17 +174,19 @@ describe "TabView", -> setData: (key, value) -> @data[key] = value getData: (key) -> @data[key] + editor.hiddenInput.focusout() tabs.onDragStart(event) sortableElement = [tabs.find('.tab:eq(1)')] tabs.onDrop(event) expect(tabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" expect(tabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" + expect(editor.isFocused).toBeTruthy() describe "when a tab is dragged from one editor and dropped onto another editor", -> - it "moves the edit session and updates the order of the tabs", -> + it "moves the edit session, updates the order of the tabs, and focuses the destination editor", -> leftTabs = tabs - editor.splitRight() + rightEditor = editor.splitRight() rightTabs = rootView.find('.tabs:last').view() sortableElement = [leftTabs.find('.tab:eq(0)')] @@ -197,6 +199,7 @@ describe "TabView", -> setData: (key, value) -> @data[key] = value getData: (key) -> @data[key] + rightEditor.hiddenInput.focusout() tabs.onDragStart(event) event.target = rightTabs @@ -205,3 +208,4 @@ describe "TabView", -> expect(rightTabs.find('.tab:eq(0) .file-name').text()).toBe "sample.txt" expect(rightTabs.find('.tab:eq(1) .file-name').text()).toBe "sample.js" + expect(rightEditor.isFocused).toBeTruthy()