From d3878cc8dfb353029af8c90fc6365cd6128984ee Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Thu, 3 Nov 2016 10:24:38 +0100 Subject: [PATCH] Don't resize terminal if we don't receive a resize control (e.g. onAttach) - Fix text selection in terminal (was our force focus stuff, introduced if you clicked on the black border that was not actually the terminal --- client/app/scripts/components/terminal.js | 17 ++++++----------- client/app/scripts/utils/web-api-utils.js | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/client/app/scripts/components/terminal.js b/client/app/scripts/components/terminal.js index cdde58833..76659f854 100644 --- a/client/app/scripts/components/terminal.js +++ b/client/app/scripts/components/terminal.js @@ -8,7 +8,7 @@ import classNames from 'classnames'; import { clickCloseTerminal } from '../actions/app-actions'; import { getNeutralColor } from '../utils/color-utils'; import { setDocumentTitle } from '../utils/title-utils'; -import { getPipeStatus, basePath, doResizePipe } from '../utils/web-api-utils'; +import { getPipeStatus, basePath, doResizeTty } from '../utils/web-api-utils'; import Term from 'xterm'; const wsProto = location.protocol === 'https:' ? 'wss' : 'ws'; @@ -97,7 +97,6 @@ class Terminal extends React.Component { this.handleCloseClick = this.handleCloseClick.bind(this); this.handlePopoutTerminal = this.handlePopoutTerminal.bind(this); this.handleResize = this.handleResize.bind(this); - this.focusTerminal = this.focusTerminal.bind(this); } createWebsocket(term) { @@ -237,12 +236,6 @@ class Terminal extends React.Component { this.props.dispatch(clickCloseTerminal(this.getPipeId(), true)); } - focusTerminal() { - if (this.term) { - this.term.focus(); - } - } - handlePopoutTerminal(ev) { ev.preventDefault(); const paramString = JSON.stringify(this.props); @@ -261,8 +254,11 @@ class Terminal extends React.Component { const cols = Math.floor(width / this.state.characterWidth); const rows = Math.floor(height / this.state.characterHeight); - doResizePipe(this.getPipeId(), this.props.pipe.get('resizeTtyControl'), cols, rows) - .then(() => this.setState({cols, rows})); + const resizeTtyControl = this.props.pipe.get('resizeTtyControl'); + if (resizeTtyControl) { + doResizeTty(this.getPipeId(), resizeTtyControl, cols, rows) + .then(() => this.setState({cols, rows})); + } } isEmbedded() { @@ -353,7 +349,6 @@ class Terminal extends React.Component {
{this.isEmbedded() && this.getTerminalHeader()}
this.innerFlex = ref} className={innerClassName} style={innerFlexStyle} > diff --git a/client/app/scripts/utils/web-api-utils.js b/client/app/scripts/utils/web-api-utils.js index 99e254b84..e8c2ec98b 100644 --- a/client/app/scripts/utils/web-api-utils.js +++ b/client/app/scripts/utils/web-api-utils.js @@ -253,7 +253,7 @@ export function doControlRequest(nodeId, control, dispatch) { } -export function doResizePipe(pipeId, control, cols, rows) { +export function doResizeTty(pipeId, control, cols, rows) { const url = `api/control/${encodeURIComponent(control.probeId)}/` + `${encodeURIComponent(control.nodeId)}/${control.id}`;