[Fix] Fix mouse click for the autocomplete at the api pane (#5929)
* Set editor height in compact mode when not in focus
This commit is contained in:
parent
dc012be1de
commit
dff61da5ac
|
|
@ -25,7 +25,7 @@
|
||||||
"marketPlaceapi": ".t--eachProviderCard p",
|
"marketPlaceapi": ".t--eachProviderCard p",
|
||||||
"addPageButton": ".t--addToPageBtn",
|
"addPageButton": ".t--addToPageBtn",
|
||||||
"apidocumentaionLink": ".t--apiDocumentationLink",
|
"apidocumentaionLink": ".t--apiDocumentationLink",
|
||||||
"postbody": "(//div[contains(@class,'CodeMirror-wrap')]//textarea)[1]",
|
"postbody": "(//div[contains(@class,'CodeMirror-wrap')]//textarea)[2]",
|
||||||
"paginationTab": "li:contains('Pagination')",
|
"paginationTab": "li:contains('Pagination')",
|
||||||
"apiInputTab": "li:contains('API Input')",
|
"apiInputTab": "li:contains('API Input')",
|
||||||
"paginationOption": ".t--apiFormPaginationType div>input",
|
"paginationOption": ".t--apiFormPaginationType div>input",
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ class CodeEditor extends Component<Props, State> {
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
autoCloseBrackets: true,
|
autoCloseBrackets: true,
|
||||||
indentWithTabs: this.props.tabBehaviour === TabBehaviour.INDENT,
|
indentWithTabs: this.props.tabBehaviour === TabBehaviour.INDENT,
|
||||||
lineWrapping: this.props.size !== EditorSize.COMPACT,
|
lineWrapping: true,
|
||||||
lineNumbers: this.props.showLineNumbers,
|
lineNumbers: this.props.showLineNumbers,
|
||||||
addModeClass: true,
|
addModeClass: true,
|
||||||
matchBrackets: false,
|
matchBrackets: false,
|
||||||
|
|
@ -261,9 +261,7 @@ class CodeEditor extends Component<Props, State> {
|
||||||
// Safe update of value of the editor when value updated outside the editor
|
// Safe update of value of the editor when value updated outside the editor
|
||||||
const inputValue = getInputValue(this.props.input.value);
|
const inputValue = getInputValue(this.props.input.value);
|
||||||
if (!!inputValue || inputValue === "") {
|
if (!!inputValue || inputValue === "") {
|
||||||
if (this.props.size === EditorSize.COMPACT) {
|
if (inputValue !== editorValue) {
|
||||||
this.editor.setValue(removeNewLineChars(inputValue));
|
|
||||||
} else if (inputValue !== editorValue) {
|
|
||||||
this.editor.setValue(inputValue);
|
this.editor.setValue(inputValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -327,14 +325,6 @@ class CodeEditor extends Component<Props, State> {
|
||||||
|
|
||||||
handleEditorFocus = () => {
|
handleEditorFocus = () => {
|
||||||
this.setState({ isFocused: true });
|
this.setState({ isFocused: true });
|
||||||
if (this.props.size === EditorSize.COMPACT) {
|
|
||||||
this.editor.operation(() => {
|
|
||||||
const inputValue = this.props.input.value;
|
|
||||||
this.editor.setOption("lineWrapping", true);
|
|
||||||
this.editor.setValue(inputValue);
|
|
||||||
this.editor.setCursor(inputValue.length);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (this.editor.getValue().length === 0)
|
if (this.editor.getValue().length === 0)
|
||||||
this.handleAutocompleteVisibility(this.editor);
|
this.handleAutocompleteVisibility(this.editor);
|
||||||
};
|
};
|
||||||
|
|
@ -342,9 +332,6 @@ class CodeEditor extends Component<Props, State> {
|
||||||
handleEditorBlur = () => {
|
handleEditorBlur = () => {
|
||||||
this.handleChange();
|
this.handleChange();
|
||||||
this.setState({ isFocused: false });
|
this.setState({ isFocused: false });
|
||||||
if (this.props.size === EditorSize.COMPACT) {
|
|
||||||
this.editor.setOption("lineWrapping", false);
|
|
||||||
}
|
|
||||||
this.editor.setOption("matchBrackets", false);
|
this.editor.setOption("matchBrackets", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -243,6 +243,14 @@ export const EditorWrapper = styled.div<{
|
||||||
position: relative;
|
position: relative;
|
||||||
`}
|
`}
|
||||||
${(props) => (props.isFocused ? `z-index: 3;` : `z-index: 0;`)}
|
${(props) => (props.isFocused ? `z-index: 3;` : `z-index: 0;`)}
|
||||||
|
|
||||||
|
${(props) => {
|
||||||
|
let height = props.height || "auto";
|
||||||
|
if (props.size === EditorSize.COMPACT && !props.isFocused) {
|
||||||
|
height = props.height || "32px";
|
||||||
|
}
|
||||||
|
return `height: ${height}`;
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,9 @@ describe("DynamicInputTextControl", () => {
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
|
|
||||||
const input = screen.getAllByText("My test value")[0];
|
|
||||||
userEvent.type(input, "New text");
|
|
||||||
waitFor(async () => {
|
waitFor(async () => {
|
||||||
|
const input = screen.getAllByText("My test value")[0];
|
||||||
|
userEvent.type(input, "New text");
|
||||||
await expect(screen.getAllByText("New text")).toHaveLength(2);
|
await expect(screen.getAllByText("New text")).toHaveLength(2);
|
||||||
await expect(screen.findByText("My test value")).toBeNull();
|
await expect(screen.findByText("My test value")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user