Skip to content

Commit 6a185b3

Browse files
authored
Merge pull request #40889 from appsmithorg/release
09/06 Daily Promotion
2 parents 5ee2044 + 99db0a1 commit 6a185b3

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

app/client/cypress/support/Pages/AggregateHelper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import EditorNavigator from "./EditorNavigation";
88
import { EntityType } from "./EditorNavigation";
99
import ClickOptions = Cypress.ClickOptions;
1010
import { DEBOUNCE_WAIT_TIME_ON_INPUT_CHANGE } from "../../../src/constants/WidgetConstants";
11+
const {
12+
SAVE_TRIGGER_DELAY_MS,
13+
} = require("../../../src/components/editorComponents/CodeEditor/debounceConstants");
1114

1215
type ElementType = string | JQuery<HTMLElement>;
1316

@@ -296,6 +299,11 @@ export class AggregateHelper {
296299
}
297300

298301
public AssertAutoSave() {
302+
// After fix made in https://github.com/appsmithorg/appsmith/pull/40239 to make save state and nw call in sync
303+
// We will need to wait for the debounced time before we make any assertions on save state, otherwise
304+
// we might run into situation where absence of save is asserted but save actually hasn't happened
305+
// Additional 100ms added to avoid flaky issues that might be caused by race condition.
306+
this.Sleep(SAVE_TRIGGER_DELAY_MS + 100);
299307
let saveStatus = this.CheckForPageSaveError();
300308
// wait for save query to trigger & n/w call to finish occuring
301309
if (!saveStatus)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const SAVE_TRIGGER_DELAY_MS = 600;

app/client/src/components/editorComponents/CodeEditor/index.tsx

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ import { getEachEntityInformation } from "ee/utils/autocomplete/EntityDefinition
161161
import { getCurrentPageId } from "selectors/editorSelectors";
162162
import { executeCommandAction } from "actions/pluginActionActions";
163163
import { PEEK_OVERLAY_DELAY } from "./PeekOverlayPopup/constants";
164+
import { SAVE_TRIGGER_DELAY_MS } from "./debounceConstants";
164165

165166
type ReduxStateProps = ReturnType<typeof mapStateToProps>;
166167
type ReduxDispatchProps = ReturnType<typeof mapDispatchToProps>;
@@ -269,8 +270,6 @@ interface State {
269270
isOpened: boolean;
270271
autoCompleteVisible: boolean;
271272
hinterOpen: boolean;
272-
// Flag for determining whether the entity change has been started or not so that even if the initial and final value remains the same, the status should be changed to not loading
273-
changeStarted: boolean;
274273
ctrlPressed: boolean;
275274
peekOverlayProps:
276275
| (PeekOverlayStateProps & {
@@ -314,7 +313,6 @@ class CodeEditor extends Component<Props, State> {
314313
isOpened: false,
315314
autoCompleteVisible: false,
316315
hinterOpen: false,
317-
changeStarted: false,
318316
ctrlPressed: false,
319317
peekOverlayProps: undefined,
320318
showAIWindow: false,
@@ -1309,17 +1307,17 @@ class CodeEditor extends Component<Props, State> {
13091307
instance?: CodeMirror.Editor,
13101308
changeObj?: CodeMirror.EditorChangeLinkedList,
13111309
) => {
1312-
const value = this.editor?.getValue() || "";
1310+
const value = this.editor.getValue() || "";
13131311
const inputValue = this.props.input.value || "";
13141312

13151313
if (
13161314
this.props.input.onChange &&
1317-
((value !== inputValue && this.state.isFocused) ||
1318-
this.state.changeStarted)
1315+
value !== inputValue &&
1316+
this.state.isFocused
13191317
) {
1320-
this.setState({
1321-
changeStarted: false,
1322-
});
1318+
/* This action updates the status of the savingEntity to true so that any
1319+
shortcut commands do not execute before updating the entity in the store */
1320+
this.props.startingEntityUpdate();
13231321
this.props.input.onChange(value);
13241322
}
13251323

@@ -1364,29 +1362,12 @@ class CodeEditor extends Component<Props, State> {
13641362
}
13651363
};
13661364

1367-
handleDebouncedChange = _.debounce(this.handleChange, 600);
1365+
handleDebouncedChange = _.debounce(this.handleChange, SAVE_TRIGGER_DELAY_MS);
13681366

13691367
startChange = (
13701368
instance: CodeMirror.Editor,
13711369
changeObj: CodeMirror.EditorChangeLinkedList,
13721370
) => {
1373-
/* This action updates the status of the savingEntity to true so that any
1374-
shortcut commands do not execute before updating the entity in the store */
1375-
const value = this.editor.getValue() || "";
1376-
const inputValue = this.props.input.value || "";
1377-
1378-
if (
1379-
this.props.input.onChange &&
1380-
value !== inputValue &&
1381-
this.state.isFocused &&
1382-
!this.state.changeStarted
1383-
) {
1384-
this.setState({
1385-
changeStarted: true,
1386-
});
1387-
this.props.startingEntityUpdate();
1388-
}
1389-
13901371
this.hidePeekOverlay();
13911372
this.handleDebouncedChange(instance, changeObj);
13921373
};

0 commit comments

Comments
 (0)