From 0de9b09f1338bcd9118887efe11af3d36c3208ba Mon Sep 17 00:00:00 2001 From: Nick Mitchell Date: Thu, 26 Nov 2020 11:56:06 -0500 Subject: [PATCH] fix: keyboard history navigation does not work in Popup clients Fixes #6262 --- .../src/components/Client/Popup.tsx | 11 ++++++++++- .../src/components/Views/Terminal/Block/Input.tsx | 12 +++++++++--- plugins/plugin-client-default/src/index.tsx | 5 +++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/plugins/plugin-client-common/src/components/Client/Popup.tsx b/plugins/plugin-client-common/src/components/Client/Popup.tsx index 0511f0b0f67..8abfff9e648 100644 --- a/plugins/plugin-client-common/src/components/Client/Popup.tsx +++ b/plugins/plugin-client-common/src/components/Client/Popup.tsx @@ -30,6 +30,7 @@ interface Props { } interface State { + tab: KuiTab model: TabModel promptPlaceholder: string } @@ -57,12 +58,14 @@ export default class Popup extends React.PureComponent { }) this.state = { + tab: undefined, model: tabModel, promptPlaceholder: '' } } private onTabReady(tab: KuiTab) { + this.setState({ tab }) tab.REPL.pexec(this.props.commandLine.join(' '), { tab }) } @@ -78,7 +81,13 @@ export default class Popup extends React.PureComponent { > - + {this.state.tab && ( + + )} {this.props.children} diff --git a/plugins/plugin-client-common/src/components/Views/Terminal/Block/Input.tsx b/plugins/plugin-client-common/src/components/Views/Terminal/Block/Input.tsx index 847ebdc9010..5b47013298c 100644 --- a/plugins/plugin-client-common/src/components/Views/Terminal/Block/Input.tsx +++ b/plugins/plugin-client-common/src/components/Views/Terminal/Block/Input.tsx @@ -413,21 +413,27 @@ export default class Input extends InputProvider { private readonly _onRef = this.onRef.bind(this) + private willFocusBlock(evt: React.SyntheticEvent) { + if (this.props.willFocusBlock) { + this.props.willFocusBlock(evt) + } + } + /** This is the onFocus property of the active prompt */ private readonly _onFocus = (evt: React.FocusEvent) => { this.props.onInputFocus && this.props.onInputFocus(evt) - this.props.willFocusBlock(evt) + this.willFocusBlock(evt) } /** This is the onClick property of the prompt for Active blocks */ private readonly _onClickActive = (evt: React.MouseEvent) => { this.props.onInputClick && this.props.onInputClick(evt) - this.props.willFocusBlock(evt) + this.willFocusBlock(evt) } /** This is the onClick property of the prompt for Finished blocks */ private readonly _onClickFinished = whenNothingIsSelected((evt: React.MouseEvent) => { - this.props.willFocusBlock(evt) + this.willFocusBlock(evt) this.setState(curState => { if (!curState.isReEdit) { return { diff --git a/plugins/plugin-client-default/src/index.tsx b/plugins/plugin-client-default/src/index.tsx index 13fa21fb834..6415336efad 100644 --- a/plugins/plugin-client-default/src/index.tsx +++ b/plugins/plugin-client-default/src/index.tsx @@ -55,7 +55,8 @@ export default function renderMain(props: KuiProps) { {...props} toplevel={!inBrowser() && } commandLine={ - props.commandLine || [ + props.commandLine || + (!isPopup() && [ 'tab', 'new', '-s', @@ -72,7 +73,7 @@ export default function renderMain(props: KuiProps) { `kuiconfig not set ${welcomeBit}`, '--onClose', `kuiconfig set ${welcomeBit}` - ] + ]) } >