Skip to content

Commit

Permalink
fix: keyboard history navigation does not work in Popup clients
Browse files Browse the repository at this point in the history
Fixes #6262
  • Loading branch information
starpit committed Nov 27, 2020
1 parent 65e52df commit f759d42
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
11 changes: 10 additions & 1 deletion plugins/plugin-client-common/src/components/Client/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface Props {
}

interface State {
tab: KuiTab
model: TabModel
promptPlaceholder: string
}
Expand Down Expand Up @@ -57,12 +58,14 @@ export default class Popup extends React.PureComponent<Props, State> {
})

this.state = {
tab: undefined,
model: tabModel,
promptPlaceholder: ''
}
}

private onTabReady(tab: KuiTab) {
this.setState({ tab })
tab.REPL.pexec(this.props.commandLine.join(' '), { tab })
}

Expand All @@ -78,7 +81,13 @@ export default class Popup extends React.PureComponent<Props, State> {
></TabContent>
<StatusStripe>
<ContextWidgets className="kui--input-stripe-in-status-stripe">
<InputStripe promptPlaceholder={this.state.promptPlaceholder} uuid={this.state.model.uuid} />
{this.state.tab && (
<InputStripe
promptPlaceholder={this.state.promptPlaceholder}
uuid={this.state.model.uuid}
tab={this.state.tab}
/>
)}
</ContextWidgets>
{this.props.children}
</StatusStripe>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,21 +413,27 @@ export default class Input extends InputProvider {

private readonly _onRef = this.onRef.bind(this)

private willFocusBlock(evt: React.SyntheticEvent<HTMLInputElement>) {
if (this.props.willFocusBlock) {
this.props.willFocusBlock(evt)
}
}

/** This is the onFocus property of the active prompt */
private readonly _onFocus = (evt: React.FocusEvent<HTMLInputElement>) => {
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<HTMLInputElement>) => {
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<HTMLInputElement>) => {
this.props.willFocusBlock(evt)
this.willFocusBlock(evt)
this.setState(curState => {
if (!curState.isReEdit) {
return {
Expand Down
5 changes: 3 additions & 2 deletions plugins/plugin-client-default/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export default function renderMain(props: KuiProps) {
{...props}
toplevel={!inBrowser() && <Search />}
commandLine={
props.commandLine || [
props.commandLine ||
(!isPopup() && [
'tab',
'new',
'-s',
Expand All @@ -72,7 +73,7 @@ export default function renderMain(props: KuiProps) {
`kuiconfig not set ${welcomeBit}`,
'--onClose',
`kuiconfig set ${welcomeBit}`
]
])
}
>
<ContextWidgets>
Expand Down

0 comments on commit f759d42

Please sign in to comment.