mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 16:19:17 +03:00
RootView passes focus to a child element with a tabindex of -1 (if one exists)
This commit is contained in:
parent
aa7325b355
commit
d13796074b
@ -16,7 +16,7 @@ describe "RootView", ->
|
||||
rootView.focus()
|
||||
|
||||
afterEach ->
|
||||
rootView.remove()
|
||||
rootView.deactivate()
|
||||
|
||||
describe "initialize(pathToOpen)", ->
|
||||
describe "when called with a pathToOpen", ->
|
||||
@ -117,10 +117,11 @@ describe "RootView", ->
|
||||
expect(document.title).toBe editor2.getPath()
|
||||
|
||||
describe "when called with no pathToOpen", ->
|
||||
it "opens no buffer", ->
|
||||
it "opens an empty buffer", ->
|
||||
rootView.remove()
|
||||
rootView = new RootView
|
||||
expect(rootView.getEditors().length).toBe 0
|
||||
expect(rootView.getEditors().length).toBe 1
|
||||
expect(rootView.getEditors()[0].getText()).toEqual ""
|
||||
expect(document.title).toBe 'untitled'
|
||||
|
||||
describe ".serialize()", ->
|
||||
@ -145,11 +146,10 @@ describe "RootView", ->
|
||||
expect(console.error).toHaveBeenCalled()
|
||||
|
||||
describe "focus", ->
|
||||
it "can receive focus if there is no active editor, but otherwise hands off focus to the active editor", ->
|
||||
it "hands off focus to the active editor", ->
|
||||
rootView.remove()
|
||||
rootView = new RootView(require.resolve 'fixtures')
|
||||
rootView.attachToDom()
|
||||
expect(rootView).toMatchSelector(':focus')
|
||||
|
||||
rootView.open() # create an editor
|
||||
expect(rootView).not.toMatchSelector(':focus')
|
||||
@ -159,6 +159,15 @@ describe "RootView", ->
|
||||
expect(rootView).not.toMatchSelector(':focus')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
it "passes focus to element with a tabIndex of -1 if there is no active editor", ->
|
||||
rootView.remove()
|
||||
rootView = new RootView(require.resolve 'fixtures')
|
||||
rootView.activateExtension require('tree-view')
|
||||
rootView.attachToDom()
|
||||
|
||||
expect(rootView).not.toMatchSelector(':focus')
|
||||
expect(rootView.find('.tree-view')).toMatchSelector(':focus')
|
||||
|
||||
describe "panes", ->
|
||||
[pane1, newPaneContent] = []
|
||||
|
||||
|
@ -142,6 +142,7 @@ describe "TreeView", ->
|
||||
|
||||
describe "when the tree view is not focused", ->
|
||||
it "shifts focus to the tree view", ->
|
||||
rootView.open() # When we call focus below, we want an editor to become focused
|
||||
rootView.focus()
|
||||
rootView.trigger 'tree-view:toggle'
|
||||
expect(treeView).toBeVisible()
|
||||
@ -184,12 +185,14 @@ describe "TreeView", ->
|
||||
|
||||
describe "when tree-view:unfocus is triggered on the tree view", ->
|
||||
it "surrenders focus to the root view but remains open", ->
|
||||
rootView.open() # When we trigger 'tree-view:unfocus' below, we want an editor to become focused
|
||||
rootView.attachToDom()
|
||||
treeView.focus()
|
||||
expect(treeView).toMatchSelector(':focus')
|
||||
treeView.trigger 'tree-view:unfocus'
|
||||
expect(treeView).toBeVisible()
|
||||
expect(treeView).not.toMatchSelector(':focus')
|
||||
expect(rootView).toMatchSelector(':focus')
|
||||
expect(rootView.getActiveEditor().isFocused).toBeTruthy()
|
||||
|
||||
describe "when a directory's disclosure arrow is clicked", ->
|
||||
it "expands / collapses the associated directory", ->
|
||||
|
@ -62,6 +62,11 @@ class RootView extends View
|
||||
false
|
||||
else
|
||||
@setTitle(@project?.getPath())
|
||||
if focusableChild = this.find("[tabindex=-1]")
|
||||
focusableChild.focus()
|
||||
false
|
||||
else
|
||||
true
|
||||
|
||||
@on 'active-editor-path-change', (e, path) =>
|
||||
@project.setPath(path) unless @project.getRootDirectory()
|
||||
|
Loading…
Reference in New Issue
Block a user