From f4da1abe9d864e55b6f446539073e4168a6b1bc6 Mon Sep 17 00:00:00 2001 From: Druthi Polisetty Date: Mon, 31 Jul 2023 13:40:37 +0530 Subject: [PATCH] fix: UI fixes for the Signposting component (#25659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description fix: UI fixes for the Signposting component #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- .../appsmith/SignPostingBanner.tsx | 2 +- .../CodeEditor/BindingPrompt.tsx | 6 +----- .../editorComponents/CodeEditor/index.tsx | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/client/src/components/designSystems/appsmith/SignPostingBanner.tsx b/app/client/src/components/designSystems/appsmith/SignPostingBanner.tsx index ad85380950..3bb836c4ba 100644 --- a/app/client/src/components/designSystems/appsmith/SignPostingBanner.tsx +++ b/app/client/src/components/designSystems/appsmith/SignPostingBanner.tsx @@ -19,7 +19,7 @@ function SignPostingBanner(props: SignPostingBannerProps) {
- {props.isAIEnabled ? ( - <> - Use /ai to generate JS expressions - - ) : props.promptMessage ? ( + {props.promptMessage ? ( props.promptMessage ) : ( <> diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index 016d0f4783..8d67870a34 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -160,6 +160,7 @@ import type { MultiplexingModeConfig } from "components/editorComponents/CodeEdi import { MULTIPLEXING_MODE_CONFIGS } from "components/editorComponents/CodeEditor/modes"; import { getDeleteLineShortcut } from "./utils/deleteLine"; import { CodeEditorSignPosting } from "@appsmith/components/editorComponents/CodeEditorSignPosting"; +import { getFocusablePropertyPaneField } from "selectors/propertyPaneSelectors"; type ReduxStateProps = ReturnType; type ReduxDispatchProps = ReturnType; @@ -541,10 +542,24 @@ class CodeEditor extends Component { //Refresh editor when the container height is increased. this.debounceEditorRefresh(); } + + const entityInformation = this.getEntityInformation(); + const isWidgetType = entityInformation.entityType === ENTITY_TYPE.WIDGET; + + const hasFocusedValueChanged = + getEditorIdentifier(this.props) !== this.props.focusedProperty; + + if (hasFocusedValueChanged && isWidgetType) { + if (this.state.showAIWindow) { + this.setState({ showAIWindow: false }); + } + } + if (identifierHasChanged) { if (this.state.showAIWindow) { this.setState({ showAIWindow: false }); } + if (shouldFocusOnPropertyControl()) { setTimeout(() => { if (this.props.editorIsFocused) { @@ -553,6 +568,7 @@ class CodeEditor extends Component { }, 200); } } + this.editor.operation(() => { if (prevProps.lintErrors !== this.props.lintErrors) { this.lintCode(this.editor); @@ -1664,6 +1680,7 @@ const mapStateToProps = (state: AppState, props: EditorProps) => ({ featureFlags: selectFeatureFlags(state), datasourceTableKeys: getAllDatasourceTableKeys(state, props.dataTreePath), installedLibraries: selectInstalledLibraries(state), + focusedProperty: getFocusablePropertyPaneField(state), }); const mapDispatchToProps = (dispatch: any) => ({