Skip to content

Commit

Permalink
fix: compare incoming value with modal's value
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-sir committed Jun 14, 2024
1 parent 0ed42e8 commit 2cb976c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
9 changes: 4 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ All notable changes to this project will be documented in this file. See [standa

### [1.3.5](https://github.com/DTStack/molecule/compare/v1.3.4...v1.3.5) (2023-12-29)


### Bug Fixes

* fix model's value not change and add onEditorInstanceMount event ([eb93979](https://github.com/DTStack/molecule/commit/eb939798a0dd09dd46a7c1d8966a744c5749b0ca))
* fix stylelint ([f126404](https://github.com/DTStack/molecule/commit/f126404bfa0b631923c985bc6679f73800bb7182))
* **scrollBar:** disable clickable when hide track ([e15b8b6](https://github.com/DTStack/molecule/commit/e15b8b68200654863bce5077d4b98b8682f37781))
* update types ([c8d8a1f](https://github.com/DTStack/molecule/commit/c8d8a1fea19060ceb313986482d9fef8791ca124))
- fix model's value not change and add onEditorInstanceMount event ([eb93979](https://github.com/DTStack/molecule/commit/eb939798a0dd09dd46a7c1d8966a744c5749b0ca))
- fix stylelint ([f126404](https://github.com/DTStack/molecule/commit/f126404bfa0b631923c985bc6679f73800bb7182))
- **scrollBar:** disable clickable when hide track ([e15b8b6](https://github.com/DTStack/molecule/commit/e15b8b68200654863bce5077d4b98b8682f37781))
- update types ([c8d8a1f](https://github.com/DTStack/molecule/commit/c8d8a1fea19060ceb313986482d9fef8791ca124))

### [1.3.4](https://github.com/DTStack/molecule/compare/v1.3.3...v1.3.4) (2023-06-12)

Expand Down
3 changes: 3 additions & 0 deletions src/services/workbench/__tests__/editorService.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ describe('Test EditorService', () => {
expect(groups?.length).toBe(1);

const setValFn = jest.fn();
const getValFn = jest.fn();
(MonacoEditor.getModel as jest.Mock).mockImplementation(() => ({
setValue: setValFn,
getValue: getValFn,
}));

act(() => {
editor.updateTab({
id: mockTab.id,
Expand Down
20 changes: 15 additions & 5 deletions src/services/workbench/editorService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';
import { singleton, container } from 'tsyringe';
import { cloneDeep } from 'lodash';
import { cloneDeep, isString } from 'lodash';
import { Component } from 'mo/react';
import {
EditorModel,
Expand Down Expand Up @@ -337,8 +337,13 @@ export class EditorService
const model = MonacoEditor.getModel(
Uri.parse(tab.id.toString())
);
if (model) {
model.setValue(editorValue || '');
const currentValue = model?.getValue();
if (
model &&
isString(editorValue) &&
currentValue !== editorValue
) {
model.setValue(editorValue);
}
this.updateGroup(groupId, group);

Expand All @@ -362,8 +367,13 @@ export class EditorService
const model = MonacoEditor.getModel(
Uri.parse(tab.id.toString())
);
if (model) {
model.setValue(editorValue || '');
const currentValue = model?.getValue();
if (
model &&
isString(editorValue) &&
currentValue !== editorValue
) {
model.setValue(editorValue);
}
});

Expand Down

0 comments on commit 2cb976c

Please sign in to comment.