Skip to content

Commit

Permalink
fix(UVE): Automatic page refresh after saving content changes (#29439)
Browse files Browse the repository at this point in the history
### Proposed Changes
* Automatic page refresh after saving content changes 


### Videos

#### **Publish**


https://github.com/user-attachments/assets/4285ffa4-4a3b-4df2-81d7-bcc9293e047d

#### **Save**



https://github.com/user-attachments/assets/3149c501-cfe6-4ae7-bedf-f46d2ed8f108
  • Loading branch information
rjvelazco authored Aug 2, 2024
1 parent 25fb12a commit 3f7db97
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const TINYMCE_EDITOR_MOCK: unknown = {
focus: jest.fn(),
getContent: (_data: unknown) => '',
isDirty: () => false,
hasFocus: () => false
hasFocus: () => false,
setContent: jest.fn()
};

const TINYMCE_EDITOR_PROPERTY_MOCK = {
Expand Down Expand Up @@ -134,6 +135,21 @@ describe('DotEditableTextComponent', () => {
jest.spyOn(mockedDotcmsClient, 'isInsideEditor').mockReturnValue(true);
});

it('should set content with the right format when the contentlet changes', () => {
spectator.detectChanges();
mockEditorFn(spectator);

const editorComponent = spectator.query(EditorComponent) as EditorComponent;
const spySetContent = jest.spyOn(editorComponent.editor, 'setContent');

spectator.setInput('contentlet', {
...dotcmsContentletMock,
title: 'New title'
});
spectator.detectChanges();
expect(spySetContent).toHaveBeenCalledWith('New title', { format: 'text' });
});

describe('Configuration', () => {
describe('Editor Configuration', () => {
it('should set a plain mode by default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class DotEditableTextComponent implements OnInit, OnChanges {
* @memberof DotEditableTextComponent
*/
get editor() {
return this.editorComponent.editor;
return this.editorComponent?.editor;
}

/**
Expand Down Expand Up @@ -170,6 +170,9 @@ export class DotEditableTextComponent implements OnInit, OnChanges {

ngOnChanges() {
this.content = this.contentlet[this.fieldName] || '';
if (this.editor) {
this.editor.setContent(this.content, { format: this.format });
}
}

/**
Expand Down

0 comments on commit 3f7db97

Please sign in to comment.