mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 07:46:06 +08:00
fix(composer): Temporary patch for broken focus
Long term, we need to refactor this so that it's either entirely controlled or uncontrolled. Potentially use focusin?
This commit is contained in:
parent
373d224f0c
commit
bb9f9d4b84
|
@ -70,6 +70,7 @@ class ComposerEditor extends Component {
|
||||||
draftClientId: PropTypes.string,
|
draftClientId: PropTypes.string,
|
||||||
initialSelectionSnapshot: PropTypes.object,
|
initialSelectionSnapshot: PropTypes.object,
|
||||||
onFocus: PropTypes.func.isRequired,
|
onFocus: PropTypes.func.isRequired,
|
||||||
|
onBlur: PropTypes.func.isRequired,
|
||||||
onFilePaste: PropTypes.func.isRequired,
|
onFilePaste: PropTypes.func.isRequired,
|
||||||
onBodyChanged: PropTypes.func.isRequired,
|
onBodyChanged: PropTypes.func.isRequired,
|
||||||
parentActions: PropTypes.shape({
|
parentActions: PropTypes.shape({
|
||||||
|
@ -85,6 +86,7 @@ class ComposerEditor extends Component {
|
||||||
};
|
};
|
||||||
this._coreExtension = {
|
this._coreExtension = {
|
||||||
onFocus: props.onFocus,
|
onFocus: props.onFocus,
|
||||||
|
onBlur: props.onBlur,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,8 +269,8 @@ class ComposerView extends React.Component
|
||||||
@_onChangeFocusedField(enabledFields[newI])
|
@_onChangeFocusedField(enabledFields[newI])
|
||||||
|
|
||||||
_onChangeFocusedField: (focusedField) =>
|
_onChangeFocusedField: (focusedField) =>
|
||||||
@setState {focusedField}
|
@setState({focusedField})
|
||||||
if focusedField in [Fields.To, Fields.Cc, Fields.Bcc]
|
if focusedField in Fields.ParticipantFields
|
||||||
@_lastFocusedParticipantField = focusedField
|
@_lastFocusedParticipantField = focusedField
|
||||||
|
|
||||||
_onExpandParticipantFields: =>
|
_onExpandParticipantFields: =>
|
||||||
|
@ -296,7 +296,7 @@ class ComposerView extends React.Component
|
||||||
ref={Fields.Subject}
|
ref={Fields.Subject}
|
||||||
placeholder="Subject"
|
placeholder="Subject"
|
||||||
value={@state.subject}
|
value={@state.subject}
|
||||||
onFocus={ => @setState focusedField: Fields.Subject}
|
onFocus={ => @setState(focusedField: Fields.Subject) }
|
||||||
onChange={@_onChangeSubject}/>
|
onChange={@_onChangeSubject}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -316,7 +316,8 @@ class ComposerView extends React.Component
|
||||||
scrollTo: @props.scrollTo
|
scrollTo: @props.scrollTo
|
||||||
}
|
}
|
||||||
initialSelectionSnapshot: @_recoveredSelection
|
initialSelectionSnapshot: @_recoveredSelection
|
||||||
onFocus: @_onEditorFocus
|
onFocus: => @setState(focusedField: Fields.Body)
|
||||||
|
onBlur: => @setState(focusedField: null)
|
||||||
onFilePaste: @_onFilePaste
|
onFilePaste: @_onFilePaste
|
||||||
onBodyChanged: @_onBodyChanged
|
onBodyChanged: @_onBodyChanged
|
||||||
|
|
||||||
|
@ -340,9 +341,6 @@ class ComposerView extends React.Component
|
||||||
_onEditorBodyDidRender: =>
|
_onEditorBodyDidRender: =>
|
||||||
@_applyFieldFocus()
|
@_applyFieldFocus()
|
||||||
|
|
||||||
_onEditorFocus: =>
|
|
||||||
@setState(focusedField: Fields.Body)
|
|
||||||
|
|
||||||
# The contenteditable decides when to request a scroll based on the
|
# The contenteditable decides when to request a scroll based on the
|
||||||
# position of the cursor and its relative distance to this composer
|
# position of the cursor and its relative distance to this composer
|
||||||
# component. We provide it our boundingClientRect so it can calculate
|
# component. We provide it our boundingClientRect so it can calculate
|
||||||
|
|
Loading…
Reference in a new issue