Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keyboard history navigation does not work in Popup clients #6263

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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