[Fix] Hide binding prompt if auto complete is open (#5911)

* temp

* hiding binding prompt if auto suggestion box is open

* slash btn click works in api pane

* removed unnecessary code
This commit is contained in:
Pranav Kanade 2021-07-16 18:02:48 +05:30 committed by GitHub
parent 82d887338a
commit 3f34ce08e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -3,9 +3,12 @@ import { isString } from "lodash";
export const showBindingPrompt = (
showEvaluatedValue: boolean,
inputValue: any,
isHinterOpen: boolean,
): boolean => {
return (
showEvaluatedValue &&
(!isString(inputValue) || !inputValue?.includes("{{") || !inputValue)
(!isString(inputValue) ||
(!inputValue && !isHinterOpen) ||
(!inputValue?.includes("{{") && !inputValue?.includes("/")))
);
};

View File

@ -121,6 +121,7 @@ type State = {
isFocused: boolean;
isOpened: boolean;
autoCompleteVisible: boolean;
hinterOpen: boolean;
};
const CommandBtnContainer = styled.div<{ isFocused: boolean }>`
@ -153,6 +154,7 @@ class CodeEditor extends Component<Props, State> {
isFocused: false,
isOpened: false,
autoCompleteVisible: false,
hinterOpen: false,
};
this.updatePropertyValue = this.updatePropertyValue.bind(this);
}
@ -407,6 +409,7 @@ class CodeEditor extends Component<Props, State> {
});
if (hinterOpen) break;
}
this.setState({ hinterOpen });
};
handleAutocompleteHide = (cm: any, event: KeyboardEvent) => {
@ -427,10 +430,10 @@ class CodeEditor extends Component<Props, State> {
cursor?: number,
preventAutoComplete = false,
) {
this.editor.focus();
if (value) {
this.editor.setValue(value);
}
this.editor.focus();
this.editor.setCursor({
line: cursor || this.editor.lineCount() - 1,
ch: this.editor.getLine(this.editor.lineCount() - 1).length - 2,
@ -578,8 +581,11 @@ class CodeEditor extends Component<Props, State> {
<BindingPrompt
editorTheme={this.props.theme}
isOpen={
showBindingPrompt(showEvaluatedValue, input.value) &&
!_.get(this.editor, "state.completionActive")
showBindingPrompt(
showEvaluatedValue,
input.value,
this.state.hinterOpen,
) && !_.get(this.editor, "state.completionActive")
}
promptMessage={this.props.promptMessage}
showLightningMenu={this.props.showLightningMenu}