mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
fix(focus): When composing a forward, focus on the To field.
Summary: fix specs This functionality used to work but `component` isn't defined and focus: was failing. Added specs to make sure this doesn't happen again. Test Plan: Run new specs Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1583
This commit is contained in:
parent
28a6668567
commit
215dbbd3f3
2 changed files with 29 additions and 1 deletions
|
@ -264,7 +264,7 @@ class ComposerView extends React.Component
|
||||||
# focused depending on the draft type, or you can pass a field as
|
# focused depending on the draft type, or you can pass a field as
|
||||||
# the first parameter.
|
# the first parameter.
|
||||||
focus: (field = null) =>
|
focus: (field = null) =>
|
||||||
if component?.isForwardedMessage()
|
if @isForwardedMessage()
|
||||||
field ?= "textFieldTo"
|
field ?= "textFieldTo"
|
||||||
else
|
else
|
||||||
field ?= "contentBody"
|
field ?= "contentBody"
|
||||||
|
|
|
@ -179,6 +179,34 @@ describe "populated composer", ->
|
||||||
makeComposer.call @
|
makeComposer.call @
|
||||||
expect(@composer.state.showbcc).toBe true
|
expect(@composer.state.showbcc).toBe true
|
||||||
|
|
||||||
|
describe "when focus() is called", ->
|
||||||
|
describe "if a field name is provided", ->
|
||||||
|
it "should focus that field", ->
|
||||||
|
useDraft.call(@)
|
||||||
|
makeComposer.call(@)
|
||||||
|
spyOn(@composer.refs['textFieldCc'], 'focus')
|
||||||
|
@composer.focus('textFieldCc')
|
||||||
|
advanceClock(1000)
|
||||||
|
expect(@composer.refs['textFieldCc'].focus).toHaveBeenCalled()
|
||||||
|
|
||||||
|
describe "if the draft is a forward", ->
|
||||||
|
it "should focus the to field", ->
|
||||||
|
useDraft.call(@, {subject: 'Fwd: This is a test'})
|
||||||
|
makeComposer.call(@)
|
||||||
|
spyOn(@composer.refs['textFieldTo'], 'focus')
|
||||||
|
@composer.focus()
|
||||||
|
advanceClock(1000)
|
||||||
|
expect(@composer.refs['textFieldTo'].focus).toHaveBeenCalled()
|
||||||
|
|
||||||
|
describe "if the draft is a normal message", ->
|
||||||
|
it "should focus on the body", ->
|
||||||
|
useDraft.call(@)
|
||||||
|
makeComposer.call(@)
|
||||||
|
spyOn(@composer.refs['contentBody'], 'focus')
|
||||||
|
@composer.focus()
|
||||||
|
advanceClock(1000)
|
||||||
|
expect(@composer.refs['contentBody'].focus).toHaveBeenCalled()
|
||||||
|
|
||||||
describe "When sending a message", ->
|
describe "When sending a message", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
spyOn(atom, "isMainWindow").andReturn true
|
spyOn(atom, "isMainWindow").andReturn true
|
||||||
|
|
Loading…
Reference in a new issue