mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48:23 +01:00
fix cmdinput cursor positioning on mount (#620)
This commit is contained in:
parent
35e0488f7b
commit
8c63be4ea0
@ -334,6 +334,19 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
|
||||
|
||||
componentDidMount() {
|
||||
this.handleComponentDidMount();
|
||||
this.updateCursorPosIfForced();
|
||||
}
|
||||
|
||||
updateCursorPosIfForced() {
|
||||
const inputModel = GlobalModel.inputModel;
|
||||
const fcpos = inputModel.forceCursorPos.get();
|
||||
if (fcpos != null && fcpos != appconst.NoStrPos) {
|
||||
if (this.mainInputRef.current != null) {
|
||||
this.mainInputRef.current.selectionStart = fcpos;
|
||||
this.mainInputRef.current.selectionEnd = fcpos;
|
||||
}
|
||||
inputModel.forceCursorPos.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
@mobx.action
|
||||
@ -347,14 +360,7 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
|
||||
this.lastFocusType = focusType;
|
||||
}
|
||||
const inputModel = GlobalModel.inputModel;
|
||||
const fcpos = inputModel.forceCursorPos.get();
|
||||
if (fcpos != null && fcpos != appconst.NoStrPos) {
|
||||
if (this.mainInputRef.current != null) {
|
||||
this.mainInputRef.current.selectionStart = fcpos;
|
||||
this.mainInputRef.current.selectionEnd = fcpos;
|
||||
}
|
||||
inputModel.forceCursorPos.set(null);
|
||||
}
|
||||
this.updateCursorPosIfForced();
|
||||
if (inputModel.forceInputFocus) {
|
||||
inputModel.forceInputFocus = false;
|
||||
this.setFocus();
|
||||
@ -614,7 +620,6 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: ()
|
||||
|
||||
const renderCmdInputKeybindings = inputModel.shouldRenderAuxViewKeybindings(null);
|
||||
const renderHistoryKeybindings = inputModel.shouldRenderAuxViewKeybindings(appconst.InputAuxView_History);
|
||||
|
||||
return (
|
||||
<div
|
||||
className="textareainput-div control is-expanded"
|
||||
|
Loading…
Reference in New Issue
Block a user