Commit 65e41b45 authored by Arnold Hendriks's avatar Arnold Hendriks

[backport] fix rte save-modify-revert not actually reverting - webhare/webhare#1449

parent f6932b27
......@@ -125,8 +125,8 @@ export default class ObjRTE extends ComponentBase
setValue(newvalue) //set from server
{
if(this.untouchedcontent == newvalue.value && !this.rte.isDirty())
return console.log("RTE: server sent an unneeded update");
if(this.untouchedcontent && this.untouchedcontent == newvalue.value)
return; //server sent an unneeded update
this.untouchedcontent = newvalue.value;
this.valuegeneration = newvalue.valuegeneration;
......@@ -510,6 +510,7 @@ export default class ObjRTE extends ComponentBase
_gotDirty()
{
++this.valuedirtycount;
this.untouchedcontent = null; //invalidate cached 'original'
this.queueMessage("dirty", { valuedirtycount: this.valuedirtycount, valuegeneration: this.valuegeneration });
}
......
......@@ -6,6 +6,16 @@ import { encodeValue } from 'dompack/types/text';
let instanceref; // instance ref at the frontend side
let instanceid; // instance id at the backend site
async function setRawHTML(code)
{
test.clickTolliumButton("Edit raw html");
await test.wait("ui");
test.compByName('code').querySelector('textarea').value = code;
test.clickTolliumButton("OK");
await test.wait("ui");
}
test.registerTests(
[ { loadpage: test.getTestScreen('tests/richdoc.main')
, waits: [ 'ui' ]
......@@ -373,6 +383,44 @@ test.registerTests(
}
}
, "Test another dirtyness regression"
, async function(doc, win)
{
/* when
- making a simple change
- forcing undirty
- sending the original version from the server to the client
the client may ignore this revert */
//load up simple enough content to trigger the RTE 'unchanged content' optimization
await setRawHTML(`<html><body><h2 class="heading2">test changes</h2></body</html>`);
//make a trivial change, verify dirty state flips
test.eq('NO', test.compByName('dirty').querySelector('input').value);
let body = test.compByName('structured').querySelector(".wh-rtd-editor-bodynode");
body.querySelector("h2").textContent = "another change";
var rte = rtetest.getRTE(win,'structured');
rte._gotStateChange();
await test.wait("ui");
test.eq('YES', test.compByName('dirty').querySelector('input').value);
//force undirty
test.clickTolliumButton("Undirty");
await test.wait("ui");
test.eq('NO', test.compByName('dirty').querySelector('input').value);
//reload the initial value
await setRawHTML(`<html><body><h2 class="heading2">test changes</h2></body</html>`);
//did the RTE pick this up?
body = test.compByName('structured').querySelector(".wh-rtd-editor-bodynode");
test.eq("test changes", body.querySelector("h2").textContent);
test.eq('NO', test.compByName('dirty').querySelector('input').value);
}
, { name: "Test image copypaste within document"
, test: async function(doc, win)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment