[FIX] web_editor: activate the redo button when needed
Because the `_historyStepsStates` was not fully set at the time of calling `historyStep` in `historyUndo` or `historyRedo`, the listener for the event "historyStep" was triggered to early and `historyCanRedo` at that time could not possibly be accurate. This commit call `historyStep` after setting all ids in `_historyStepsStates`. task-2667885 X-original-commit: 659b530516e13df77eed6254b81e72b8009a71bf Part-of: odoo/odoo#79620
This commit is contained in:
@@ -637,7 +637,7 @@ export class OdooEditor extends EventTarget {
|
||||
}
|
||||
|
||||
// One step completed: apply to vDOM, setup next history step
|
||||
historyStep(skipRollback = false) {
|
||||
historyStep(skipRollback = false, { stepId } = {}) {
|
||||
if (!this._historyStepsActive) {
|
||||
return;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ export class OdooEditor extends EventTarget {
|
||||
return false;
|
||||
}
|
||||
|
||||
currentStep.id = this._generateId();
|
||||
currentStep.id = stepId || this._generateId();
|
||||
const previousStep = peek(this._historySteps);
|
||||
currentStep.clientId = this._collabClientId;
|
||||
currentStep.previousStepId = previousStep.id;
|
||||
@@ -752,10 +752,10 @@ export class OdooEditor extends EventTarget {
|
||||
// Consider the position consumed.
|
||||
this._historyStepsStates.set(this._historySteps[pos].id, 'consumed');
|
||||
this.historyRevert(this._historySteps[pos]);
|
||||
this.historyStep(true);
|
||||
// Consider the last position of the history as an undo.
|
||||
const undoStep = this._historySteps[this._historySteps.length - 1];
|
||||
this._historyStepsStates.set(undoStep.id, 'undo');
|
||||
const stepId = this._generateId();
|
||||
this._historyStepsStates.set(stepId, 'undo');
|
||||
this.historyStep(true, { stepId });
|
||||
this.dispatchEvent(new Event('historyUndo'));
|
||||
}
|
||||
}
|
||||
@@ -770,9 +770,9 @@ export class OdooEditor extends EventTarget {
|
||||
this._historyStepsStates.set(this._historySteps[pos].id, 'consumed');
|
||||
this.historyRevert(this._historySteps[pos]);
|
||||
this.historySetSelection(this._historySteps[pos]);
|
||||
this.historyStep(true);
|
||||
const lastStep = this._historySteps[this._historySteps.length - 1];
|
||||
this._historyStepsStates.set(lastStep.id, 'redo');
|
||||
const stepId = this._generateId();
|
||||
this._historyStepsStates.set(stepId, 'redo');
|
||||
this.historyStep(true, { stepId });
|
||||
this.dispatchEvent(new Event('historyRedo'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user