Preserve drafts on empty clear directives

This commit is contained in:
Meta Vens 2026-08-22 19:12:34 +02:00
commit af05248af5
3 changed files with 16 additions and 2 deletions

View file

@ -16,7 +16,7 @@ export class EveBrowserDraftStore {
this.values.set(this.key(providerId, surfaceId, bindingName), value);
}
clear(providerId, surfaceId, bindingNames) {
if (bindingNames?.length) {
if (bindingNames !== undefined) {
for (const name of bindingNames)
this.values.delete(this.key(providerId, surfaceId, name));
return;

View file

@ -167,7 +167,7 @@ export class EveBrowserDraftStore {
}
clear(providerId: string, surfaceId: string, bindingNames?: readonly string[]): void {
if (bindingNames?.length) {
if (bindingNames !== undefined) {
for (const name of bindingNames) this.values.delete(this.key(providerId, surfaceId, name));
return;
}

View file

@ -265,6 +265,20 @@ test("editable bindings preserve local drafts across authoritative refresh and o
}
});
test("an explicit empty draft directive clears no unrelated bindings", () => {
const drafts = new EveBrowserDraftStore();
drafts.set("ghostlight", "ghostlight.play", "channel_id", "private:host");
drafts.set("ghostlight", "ghostlight.play", "message", "still drafting");
drafts.clear("ghostlight", "ghostlight.play", []);
assert.equal(drafts.get("ghostlight", "ghostlight.play", "channel_id"), "private:host");
assert.equal(drafts.get("ghostlight", "ghostlight.play", "message"), "still drafting");
drafts.clear("ghostlight", "ghostlight.play");
assert.equal(drafts.has("ghostlight", "ghostlight.play", "channel_id"), false);
assert.equal(drafts.has("ghostlight", "ghostlight.play", "message"), false);
});
test("operations capture untouched authored choice defaults", () => {
const restoreDom = installDom();
try {