Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(edit-page-2): Fix scrolling issue #28469 #28491

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,9 @@ describe('EditEmaStore', () => {
});
});

it('should update editor state to dragginf when have dragItem', (done) => {
it('should update editor state to dragging when have dragItem', (done) => {
spectator.service.setDragItem({} as EmaDragItem);
spectator.service.updateEditorScrollState();
spectator.service.updateEditorDragState();

spectator.service.editorState$.subscribe((state) => {
expect(state).toEqual({
Expand All @@ -561,6 +561,31 @@ describe('EditEmaStore', () => {
done();
});
});

it('should update editor state to idle when dont have dragItem', (done) => {
spectator.service.updateEditorDragState();

spectator.service.editorState$.subscribe((state) => {
expect(state).toEqual({
...state,
state: EDITOR_STATE.IDLE
});
done();
});
});

it('should update editor state to scroll-drag when have dragItem', () => {
spectator.service.setDragItem({} as EmaDragItem);
spectator.service.updateEditorScrollState();

spectator.service.editorState$.subscribe((state) => {
expect(state).toEqual({
...state,
bounds: [],
state: EDITOR_STATE.SCROLL_DRAG
});
});
});
});

describe('effects', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
editorData.canEditVariant &&
!editorData.device &&
(currentState === EDITOR_STATE.DRAGGING ||
currentState === EDITOR_STATE.SCROLLING),
currentState === EDITOR_STATE.SCROLL_DRAG),
showPalette:
editorData.canEditVariant &&
isEnterpriseLicense &&
Expand Down Expand Up @@ -736,7 +736,7 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
readonly setScrollingState = this.updater((state) => {
return {
...state,
editorState: EDITOR_STATE.SCROLLING,
editorState: EDITOR_STATE.SCROLL_DRAG,
bounds: []
};
});
Expand Down Expand Up @@ -765,6 +765,22 @@ export class EditEmaStore extends ComponentStore<EditEmaState> {
* @returns The updated dot-ema store state.
*/
readonly updateEditorScrollState = this.updater((state) => {
const newState = state.dragItem
? {
...state,
editorState: EDITOR_STATE.SCROLL_DRAG
}
: {
...state,
editorState: EDITOR_STATE.IDLE,
bounds: [],
contentletArea: undefined
};

return newState;
});

readonly updateEditorDragState = this.updater((state) => {
return {
...state,
editorState: state.dragItem ? EDITOR_STATE.DRAGGING : EDITOR_STATE.IDLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,10 @@ export class EditEmaEditorComponent implements OnInit, OnDestroy {
});
},
[CUSTOMER_ACTIONS.IFRAME_SCROLL]: () => {
this.store.updateEditorState(EDITOR_STATE.SCROLLING);
this.store.updateEditorScrollState();
},
[CUSTOMER_ACTIONS.IFRAME_SCROLL_END]: () => {
this.store.updateEditorScrollState();
this.store.updateEditorDragState();
},
[CUSTOMER_ACTIONS.PING_EDITOR]: () => {
this.iframe?.nativeElement?.contentWindow.postMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export enum EDITOR_STATE {
DRAGGING = 'dragging',
ERROR = 'error',
OUT_OF_BOUNDS = 'out-of-bounds',
SCROLLING = 'scrolling'
SCROLL_DRAG = 'scroll-drag'
}

export enum EDITOR_MODE {
Expand Down
2 changes: 1 addition & 1 deletion dotCMS/src/main/webapp/html/js/editor-js/sdk-editor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading